Browse Source

test: fix losing original env vars issue

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: https://github.com/nodejs/node/pull/3190
v4.x
Junliang Yan 9 years ago
committed by James M Snell
parent
commit
26a7ec6960
  1. 2
      test/parallel/test-child-process-spawnsync-env.js
  2. 2
      test/parallel/test-fs-readfile-error.js
  3. 12
      test/sequential/test-net-GH-5504.js
  4. 4
      test/sequential/test-stdin-script-child.js
  5. 7
      test/sequential/test-util-debug.js

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

@ -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);

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

@ -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, '');

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

@ -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);
@ -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>');

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

@ -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 = '';

7
test/sequential/test-util-debug.js

@ -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);

Loading…
Cancel
Save