test: pass process.env to child processes

For variables such as LD_LIBRARY_PATH and DYLD_LIBRARY_PATH that are
needed for dynamically linked binaries

PR-URL: https://github.com/nodejs/node/pull/16405
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
pull/16876/head
Rod Vagg 2017-10-23 18:47:39 +11:00
parent 5e1e460ac1
commit 3b3ceafaf9
4 changed files with 7 additions and 9 deletions

View File

@ -91,11 +91,9 @@ class TestDoubleBenchmarker {
create(options) {
const child = child_process.fork(this.executable, {
silent: true,
env: {
duration: options.duration,
connections: options.connections,
path: `http://127.0.0.1:${options.port}${options.path}`
}
env: Object.assign({}, process.env, {
test_url: `http://127.0.0.1:${options.port}${options.path}`
})
});
return child;
}

View File

@ -2,6 +2,6 @@
const http = require('http');
http.get(process.env.path, function() {
http.get(process.env.test_url, function() {
console.log(JSON.stringify({ throughput: 1 }));
});

View File

@ -8,7 +8,7 @@ const expected = common.isWindows ? '%foo%' : '$foo';
if (process.argv[2] === undefined) {
const child = cp.fork(__filename, [expected], {
shell: true,
env: { foo: 'bar' }
env: Object.assign({}, process.env, { foo: 'bar' })
});
child.on('exit', common.mustCall((code, signal) => {

View File

@ -311,11 +311,11 @@ function workerProcessMain() {
function spawnMaster({ execArgv, workers, clusterSettings = {} }) {
return new Promise((resolve) => {
childProcess.fork(__filename, {
env: {
env: Object.assign({}, process.env, {
workers: JSON.stringify(workers),
clusterSettings: JSON.stringify(clusterSettings),
testProcess: true
},
}),
execArgv
}).on('exit', common.mustCall((code, signal) => {
checkExitCode(code, signal);