Skip to content

Commit

Permalink
test: fix losing original env vars issue
Browse files Browse the repository at this point in the history
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
PR-URL: #3190
  • Loading branch information
Junliang Yan authored and jasnell committed Oct 8, 2015
1 parent 9136359 commit 26a7ec6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-spawnsync-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (process.argv[2] === 'child') {
} else {
var expected = 'bar';
var child = cp.spawnSync(process.execPath, [__filename, 'child'], {
env: {foo: expected}
env: Object.assign(process.env, { foo: expected })
});

assert.equal(child.stdout.toString().trim(), expected);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-readfile-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
exec(execPath, options, function(err, stdout, stderr) {
assert(err);
assert.equal(stdout, '');
Expand Down
12 changes: 5 additions & 7 deletions test/sequential/test-net-GH-5504.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ function parent() {
var serverExited = false;
var clientExited = false;
var serverListened = false;
var opt = {
env: {
NODE_DEBUG: 'net',
NODE_COMMON_PORT: process.env.NODE_COMMON_PORT,
}
};

process.on('exit', function() {
assert(serverExited);
Expand All @@ -75,7 +69,11 @@ function parent() {
});
}, common.platformTimeout(2000)).unref();

var s = spawn(node, [__filename, 'server'], opt);
var s = spawn(node, [__filename, 'server'], {
env: Object.assign(process.env, {
NODE_DEBUG: 'net'
})
});
var c;

wrap(s.stderr, process.stderr, 'SERVER 2>');
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-stdin-script-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ var assert = require('assert');

var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [], {
env: {
env: Object.assign(process.env, {
NODE_DEBUG: process.argv[2]
}
})
});
var wanted = child.pid + '\n';
var found = '';
Expand Down
7 changes: 1 addition & 6 deletions test/sequential/test-util-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ function test(environ, shouldWrite) {

var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [__filename, 'child'], {
// Lttng requires the HOME env variable or it prints to stderr,
// This is not really ideal, as it breaks this test, so the HOME
// 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.
env: { NODE_DEBUG: environ, HOME: process.env.HOME }
env: Object.assign(process.env, { NODE_DEBUG: environ })
});

expectErr = expectErr.split('%PID%').join(child.pid);
Expand Down

0 comments on commit 26a7ec6

Please sign in to comment.