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

Fix missing original env variable issue on multiple test cases. #3190

Closed
wants to merge 1 commit into from

Conversation

john-yan
Copy link

@john-yan john-yan commented Oct 5, 2015

When the parent spawn the child processes, the environment variables passing into the child processes are missing the original env variables passing into the parent. Some missing variables like LD_LIBRARY_PATH cause the child processes unable to run.

PR-URL: #3183

@rvagg
Copy link
Member

rvagg commented Oct 5, 2015

copied my comments from #3191

lgtm

I imagine the proper way to do this is with Object.assign() but since it's tests I'm not sure it matters, anyone else have an opinion on that?

@mscdex mscdex added the test Issues and PRs related to the tests. label Oct 6, 2015
@mhdawson mhdawson self-assigned this Oct 6, 2015
@mhdawson
Copy link
Member

mhdawson commented Oct 6, 2015

I think @cjihrig was suggesting using this approach

env: util._extend(process.env, {NODE_DEBUG: process.argv[2]})

@john-yan
Copy link
Author

john-yan commented Oct 6, 2015

@rvagg @cjihrig @mhdawson Hello, I don't mind to change to Object.assign, extend or something else, because it shouldn't make any difference from the testing perspective. But which one do you agree on?

@cjihrig
Copy link
Contributor

cjihrig commented Oct 6, 2015

I forgot we have Object.assign() now. If you can use that, that's probably the correct approach.

@john-yan john-yan force-pushed the master branch 2 times, most recently from 8a16df9 to 7e8844d Compare October 6, 2015 23:52
@john-yan
Copy link
Author

john-yan commented Oct 6, 2015

@rvagg @cjihrig Redo commit with Object.assign()

@@ -16,7 +16,7 @@ var callbacks = 0;
function test(env, cb) {
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
var execPath = '"' + process.execPath + '" "' + filename + '"';
var options = { env: env || {} };
var options = { env: Object.assign(process.env, env) || {} };
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can drop the || {} now.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

// env variable is passed to the child to make the test pass.
// this is fixed in the next version of lttng (2.7+), so we can
// remove it at sometime in the future.
HOME: process.env.HOME
Copy link
Contributor

Choose a reason for hiding this comment

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

Is HOME still required? Seems like it should get copied over now.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, thanks, you are right. Home should be copied over. Fixed.

@cjihrig
Copy link
Contributor

cjihrig commented Oct 7, 2015

LGTM

@mhdawson
Copy link
Member

mhdawson commented Oct 7, 2015

lgtm will land tomorrow

@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

Seeing a CI failure on freebsd (https://ci.nodejs.org/job/node-test-commit-other/854/nodes=freebsd101-64/console) that may be related to this commit.

not ok 886 test-child-process-emfile.js
#
#assert.js:89
#  throw new assert.AssertionError({
#  ^
#AssertionError: 0 undefined null
#    at emitTwo (events.js:87:13)
#    at ChildProcess.emit (events.js:172:7)
#    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

@john-yan @mhdawson ... can you please investigate before landing in master. If landed in master in time, I'll pick it back to v4.x but not sure it'll make it for v4.2.0

@evanlucas
Copy link
Contributor

I've been seeing that test fail more often

@jbergstroem
Copy link
Member

Pretty sure that test isn't related: #3193

@LinusU
Copy link
Contributor

LinusU commented Oct 8, 2015

Object.assign actually modifies the first argument, should we really send process.env there?

Maybe do this instead:

- Object.assign(process.env, { foo: expected })
+ Object.assign({}, process.env, { foo: expected })

@john-yan
Copy link
Author

john-yan commented Oct 8, 2015

Hello @LinusU , looks like they wanted to extend process.env instead.

@john-yan
Copy link
Author

john-yan commented Oct 8, 2015

Hello @jasnell , Given that the changes in this commit has no global effect and no change has been made to the failing test cases in the CI, I don't think it's related.

@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

Ok. Thank you for clarifying. Running one more local test then will land on master.

jasnell pushed a commit that referenced this pull request Oct 8, 2015
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
PR-URL: #3190
@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

Landed in a9d42e0

@jasnell jasnell closed this Oct 8, 2015
jasnell pushed a commit that referenced this pull request Oct 8, 2015
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
PR-URL: #3190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants