Skip to content

Commit 26a7ec6

Browse files
Junliang Yanjasnell
Junliang Yan
authored andcommitted
test: fix losing original env vars issue
Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> PR-URL: #3190
1 parent 9136359 commit 26a7ec6

5 files changed

+10
-17
lines changed

test/parallel/test-child-process-spawnsync-env.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (process.argv[2] === 'child') {
88
} else {
99
var expected = 'bar';
1010
var child = cp.spawnSync(process.execPath, [__filename, 'child'], {
11-
env: {foo: expected}
11+
env: Object.assign(process.env, { foo: expected })
1212
});
1313

1414
assert.equal(child.stdout.toString().trim(), expected);

test/parallel/test-fs-readfile-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var callbacks = 0;
1616
function test(env, cb) {
1717
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
1818
var execPath = '"' + process.execPath + '" "' + filename + '"';
19-
var options = { env: env || {} };
19+
var options = { env: Object.assign(process.env, env) };
2020
exec(execPath, options, function(err, stdout, stderr) {
2121
assert(err);
2222
assert.equal(stdout, '');

test/sequential/test-net-GH-5504.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ function parent() {
5353
var serverExited = false;
5454
var clientExited = false;
5555
var serverListened = false;
56-
var opt = {
57-
env: {
58-
NODE_DEBUG: 'net',
59-
NODE_COMMON_PORT: process.env.NODE_COMMON_PORT,
60-
}
61-
};
6256

6357
process.on('exit', function() {
6458
assert(serverExited);
@@ -75,7 +69,11 @@ function parent() {
7569
});
7670
}, common.platformTimeout(2000)).unref();
7771

78-
var s = spawn(node, [__filename, 'server'], opt);
72+
var s = spawn(node, [__filename, 'server'], {
73+
env: Object.assign(process.env, {
74+
NODE_DEBUG: 'net'
75+
})
76+
});
7977
var c;
8078

8179
wrap(s.stderr, process.stderr, 'SERVER 2>');

test/sequential/test-stdin-script-child.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var assert = require('assert');
44

55
var spawn = require('child_process').spawn;
66
var child = spawn(process.execPath, [], {
7-
env: {
7+
env: Object.assign(process.env, {
88
NODE_DEBUG: process.argv[2]
9-
}
9+
})
1010
});
1111
var wanted = child.pid + '\n';
1212
var found = '';

test/sequential/test-util-debug.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ function test(environ, shouldWrite) {
2727

2828
var spawn = require('child_process').spawn;
2929
var child = spawn(process.execPath, [__filename, 'child'], {
30-
// Lttng requires the HOME env variable or it prints to stderr,
31-
// This is not really ideal, as it breaks this test, so the HOME
32-
// env variable is passed to the child to make the test pass.
33-
// this is fixed in the next version of lttng (2.7+), so we can
34-
// remove it at sometime in the future.
35-
env: { NODE_DEBUG: environ, HOME: process.env.HOME }
30+
env: Object.assign(process.env, { NODE_DEBUG: environ })
3631
});
3732

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

0 commit comments

Comments
 (0)