From 090534146f40094aa7b7fb58c4c8cb8fadb48a28 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 23 Oct 2017 18:47:39 +1100 Subject: [PATCH 1/2] test: pass process.env to child processes 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 | 4 ++-- test/parallel/test-child-process-fork-no-shell.js | 2 +- test/sequential/test-inspector-port-cluster.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index f9359b13d5e9e4..5db65fdbcd4fea 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -91,11 +91,11 @@ class TestDoubleBenchmarker { create(options) { const child = child_process.fork(this.executable, { silent: true, - env: { + env: Object.assign({}, process.env, { duration: options.duration, connections: options.connections, path: `http://127.0.0.1:${options.port}${options.path}` - } + }) }); return child; } 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); From edffa1d6caa17606d431339195c425193f02c08b Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 10 Nov 2017 00:37:53 +1100 Subject: [PATCH 2/2] !squash don't use 'path' env var! --- benchmark/_http-benchmarkers.js | 4 +--- benchmark/_test-double-benchmarker.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index 5db65fdbcd4fea..54b7481afaa817 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -92,9 +92,7 @@ class TestDoubleBenchmarker { const child = child_process.fork(this.executable, { silent: true, env: Object.assign({}, process.env, { - duration: options.duration, - connections: options.connections, - path: `http://127.0.0.1:${options.port}${options.path}` + 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 })); });