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
This commit is contained in:
Junliang Yan authored and James M Snell committed 2015-10-08 07:56:36 -07:00
1 parent 9136359d57
commit 26a7ec6960
5 files changed
+10 -17

No files matched your search

@@ -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);
+1 -1
View File
@@ -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, '');
+5 -7
View File
@@ -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>');
+2 -2
View File
@@ -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 = '';
+1 -6
View File
@@ -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);