Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: preserve env in test cases #14822

Closed
wants to merge 1 commit into from

Conversation

BethGriggs
Copy link
Member

Allows env vars to be passed through to child processes. This is needed for
things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared library.

Refs: #13390

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

/cc @Trott

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Aug 14, 2017
@tniessen
Copy link
Member

cc @nodejs/testing

@@ -7,6 +7,7 @@ if (process.argv[2] === 'child') {
process.emitWarning('foo');
} else {
function test(env) {
env = Object.assign({}, process.env, env);
Copy link
Member

@gibfahn gibfahn Aug 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do this to be more explicit:

   function test(newEnv) {
     const env = Object.assign({}, process.env, newEnv);

@@ -8,13 +8,16 @@ const path = require('path');

const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');

const env = Object.assign({}, process.env,
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

const child = fork(runjs, ['--set', 'dur=0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd rewrap this as:

const child = fork(
  runjs,
  [
    '--set', 'dur=0',
    '--set', 'n=1',
    '--set', 'len=1',
    '--set', 'params=1',
    '--set', 'methodName=execSync',
    'child_process'
  ],
  { env }
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR, but if @BethGriggs wants to do that that's fine too.

@refack
Copy link
Contributor

refack commented Aug 14, 2017

7 uses in 7 files in my book calls for a common utility or even a new endpoint in child_process. But that is completely up to you @BethGriggs

@refack
Copy link
Contributor

refack commented Aug 14, 2017

Ref: #14823

@gibfahn
Copy link
Member

gibfahn commented Aug 14, 2017

7 uses in 7 files in my book calls for a common utility or even a new endpoint in child_process. But that is completely up to you @BethGriggs

Agreed, but that's definitely not something for this PR (we'd have to decide which one first, and it'd be good to land this to fix these test failures ASAP, they don't fail in CI, but do on machines with long $WORKSPACE paths).

Allows env vars to be passed through to child processes. This is needed for
things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared library.

Refs: nodejs#13390
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@refack refack added the confirmed-bug Issues with confirmed bugs. label Aug 14, 2017
@refack
Copy link
Contributor

refack commented Aug 14, 2017

@gibfahn I've added the confirmed-bug label. We can agree that PRs labeled as such should avoid "scope-creep".

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

I don’t think “confirmed-bug” makes any sense here.

If you don’t want scope creep, not requesting changes that would extend scope sounds sufficient to me?

@gibfahn
Copy link
Member

gibfahn commented Aug 14, 2017

I don’t think “confirmed-bug” makes any sense here.

I'd say this is a bug in the tests, not in the source, so assuming that confirmed-bug is for the latter then I agree it doesn't apply.

@refack
Copy link
Contributor

refack commented Aug 14, 2017

I don’t think “confirmed-bug” makes any sense here.

If you don’t want scope creep, not requesting changes that would extend scope sounds sufficient to me?

I made scope-creep suggestions since I was not aware that this is a directed bug-fix. Thus I'm looking for a simple way to flag PRs as such, so future reviewers will be aware.
Since confirmed-bug doesn't have meaning for PRs (yet) it seemed like the easiest choice. Other options could be a new label.

@gibfahn
Copy link
Member

gibfahn commented Aug 16, 2017

tniessen pushed a commit that referenced this pull request Aug 16, 2017
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: #14822
Refs: #13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
@tniessen
Copy link
Member

Landed in c879c9a, thank you!

@tniessen tniessen closed this Aug 16, 2017
MSLaguana pushed a commit to nodejs/node-chakracore that referenced this pull request Aug 21, 2017
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: nodejs/node#14822
Refs: nodejs/node#13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR pushed a commit that referenced this pull request Sep 3, 2017
PR-URL: #14845
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 5, 2017
PR-URL: nodejs/node#14845
Fixes: nodejs/node#14823
Refs: nodejs/node#14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: #14822
Refs: #13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
PR-URL: #14845
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: #14822
Refs: #13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
PR-URL: #14845
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: #14822
Refs: #13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
PR-URL: #14845
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
gibfahn added a commit to gibfahn/node that referenced this pull request Sep 22, 2017
PR-URL: nodejs#14845
Backport-PR-URL: nodejs#15557
Fixes: nodejs#14823
Refs: nodejs#14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 22, 2017
PR-URL: #14845
Backport-PR-URL: #15557
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 26, 2017
PR-URL: #14845
Backport-PR-URL: #15557
Fixes: #14823
Refs: #14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Feb 20, 2018

@BethGriggs would you mind backporting this to 6.x? Guide is here.

BethGriggs added a commit to BethGriggs/node that referenced this pull request Feb 21, 2018
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

PR-URL: nodejs#14822
Refs: nodejs#13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BethGriggs BethGriggs deleted the preserve-env-vars branch February 21, 2018 15:36
MylesBorins pushed a commit that referenced this pull request Feb 27, 2018
Allows env vars to be passed through to child processes. This is needed
for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared
library.

Backport-PR-URL: #18883
PR-URL: #14822
Refs: #13390
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.