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) { create(options) {
const child = child_process.fork(this.executable, { const child = child_process.fork(this.executable, {
silent: true, silent: true,
env: { env: Object.assign({}, process.env, {
duration: options.duration, test_url: `http://127.0.0.1:${options.port}${options.path}`
connections: options.connections, })
path: `http://127.0.0.1:${options.port}${options.path}`
}
}); });
return child; return child;
} }

View File

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

View File

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

View File

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