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 { } else {
var expected = 'bar'; var expected = 'bar';
var child = cp.spawnSync(process.execPath, [__filename, 'child'], { 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); 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) { function test(env, cb) {
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js'); var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
var execPath = '"' + process.execPath + '" "' + filename + '"'; var execPath = '"' + process.execPath + '" "' + filename + '"';
var options = { env: env || {} }; var options = { env: Object.assign(process.env, env) };
exec(execPath, options, function(err, stdout, stderr) { exec(execPath, options, function(err, stdout, stderr) {
assert(err); assert(err);
assert.equal(stdout, ''); assert.equal(stdout, '');

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

@ -53,12 +53,6 @@ function parent() {
var serverExited = false; var serverExited = false;
var clientExited = false; var clientExited = false;
var serverListened = false; var serverListened = false;
var opt = {
env: {
NODE_DEBUG: 'net',
NODE_COMMON_PORT: process.env.NODE_COMMON_PORT,
}
};
process.on('exit', function() { process.on('exit', function() {
assert(serverExited); assert(serverExited);
@ -75,7 +69,11 @@ function parent() {
}); });
}, common.platformTimeout(2000)).unref(); }, 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; var c;
wrap(s.stderr, process.stderr, 'SERVER 2>'); 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 spawn = require('child_process').spawn;
var child = spawn(process.execPath, [], { var child = spawn(process.execPath, [], {
env: { env: Object.assign(process.env, {
NODE_DEBUG: process.argv[2] NODE_DEBUG: process.argv[2]
} })
}); });
var wanted = child.pid + '\n'; var wanted = child.pid + '\n';
var found = ''; var found = '';

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

@ -27,12 +27,7 @@ function test(environ, shouldWrite) {
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [__filename, 'child'], { var child = spawn(process.execPath, [__filename, 'child'], {
// Lttng requires the HOME env variable or it prints to stderr, env: Object.assign(process.env, { NODE_DEBUG: environ })
// 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 }
}); });
expectErr = expectErr.split('%PID%').join(child.pid); expectErr = expectErr.split('%PID%').join(child.pid);

Loading…
Cancel
Save