Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeth Griggs <Bethany.Griggs@uk.ibm.com>2017-08-14 14:12:49 +0300
committerMyles Borins <mylesborins@google.com>2018-02-27 10:16:33 +0300
commitfdf73b110ffadf7bc0376c606f524626a1887805 (patch)
treeda0fb2c667e34a1cad5eb06fe5b3afc6da08323e
parentd333ba5e2a02aaf67ca4d1cfc3de7b5ecceb0f8b (diff)
test: preserve env in test cases
Allows env vars to be passed through to child processes. This is needed for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared library. Backport-PR-URL: https://github.com/nodejs/node/pull/18883 PR-URL: https://github.com/nodejs/node/pull/14822 Refs: https://github.com/nodejs/node/pull/13390 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--test/parallel/test-env-var-no-warnings.js3
-rw-r--r--test/parallel/test-tls-env-bad-extra-ca.js6
-rw-r--r--test/parallel/test-tls-env-extra-ca.js4
3 files changed, 7 insertions, 6 deletions
diff --git a/test/parallel/test-env-var-no-warnings.js b/test/parallel/test-env-var-no-warnings.js
index f829443888b..ff0421c4685 100644
--- a/test/parallel/test-env-var-no-warnings.js
+++ b/test/parallel/test-env-var-no-warnings.js
@@ -6,7 +6,8 @@ const cp = require('child_process');
if (process.argv[2] === 'child') {
process.emitWarning('foo');
} else {
- function test(env) {
+ function test(newEnv) {
+ const env = Object.assign({}, process.env, newEnv);
const cmd = `"${process.execPath}" "${__filename}" child`;
cp.exec(cmd, { env }, common.mustCall((err, stdout, stderr) => {
diff --git a/test/parallel/test-tls-env-bad-extra-ca.js b/test/parallel/test-tls-env-bad-extra-ca.js
index 493b659778b..f7e9341ad00 100644
--- a/test/parallel/test-tls-env-bad-extra-ca.js
+++ b/test/parallel/test-tls-env-bad-extra-ca.js
@@ -16,10 +16,10 @@ if (process.env.CHILD) {
return tls.createServer({});
}
-const env = {
+const env = Object.assign({}, process.env, {
CHILD: 'yes',
- NODE_EXTRA_CA_CERTS: `${fixtures.fixturesDir}/no-such-file-exists`
-};
+ NODE_EXTRA_CA_CERTS: `${fixtures.fixturesDir}/no-such-file-exists`,
+});
const opts = {
env: env,
diff --git a/test/parallel/test-tls-env-extra-ca.js b/test/parallel/test-tls-env-extra-ca.js
index 5f011f33382..4dd12a78b63 100644
--- a/test/parallel/test-tls-env-extra-ca.js
+++ b/test/parallel/test-tls-env-extra-ca.js
@@ -32,11 +32,11 @@ const server = tls.createServer(options, common.mustCall(function(s) {
s.end('bye');
server.close();
})).listen(0, common.mustCall(function() {
- const env = {
+ const env = Object.assign({}, process.env, {
CHILD: 'yes',
PORT: this.address().port,
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'ca1-cert.pem')
- };
+ });
fork(__filename, {env: env}).on('exit', common.mustCall(function(status) {
assert.strictEqual(status, 0, 'client did not succeed in connecting');