From 3b3ceafaf922e1d79950595eaa501aa412913820 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 23 Oct 2017 18:47:39 +1100 Subject: [PATCH] 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 Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- benchmark/_http-benchmarkers.js | 8 +++----- benchmark/_test-double-benchmarker.js | 2 +- test/parallel/test-child-process-fork-no-shell.js | 2 +- test/sequential/test-inspector-port-cluster.js | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index f9359b13d5e9e4..54b7481afaa817 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -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; } diff --git a/benchmark/_test-double-benchmarker.js b/benchmark/_test-double-benchmarker.js index 0a8c5f9264efc8..8c2f744fbf6e9f 100644 --- a/benchmark/_test-double-benchmarker.js +++ b/benchmark/_test-double-benchmarker.js @@ -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 })); }); diff --git a/test/parallel/test-child-process-fork-no-shell.js b/test/parallel/test-child-process-fork-no-shell.js index 7a085913fbf4a3..168f115b0cbcbf 100644 --- a/test/parallel/test-child-process-fork-no-shell.js +++ b/test/parallel/test-child-process-fork-no-shell.js @@ -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) => { diff --git a/test/sequential/test-inspector-port-cluster.js b/test/sequential/test-inspector-port-cluster.js index 3b2464d81268b4..2428a7844e98c0 100644 --- a/test/sequential/test-inspector-port-cluster.js +++ b/test/sequential/test-inspector-port-cluster.js @@ -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);