Skip to content

Commit a7469da

Browse files
committed
squash! remove envPlus, use Object.assign everywhere
1 parent ead0c22 commit a7469da

25 files changed

+43
-44
lines changed

test/common/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ Platform normalizes the `dd` command
5050

5151
Check if there is more than 1gb of total memory.
5252

53-
### envPlus(additionalEnv)
54-
* return [<Object>]
55-
56-
Returns `process.env` plus `additionalEnv`. Used to pass a temporarily modified
57-
environment to a child process.
58-
5953
### expectsError([fn, ]settings[, exact])
6054
* `fn` [<Function>] a function that should throw.
6155
* `settings` [<Object>]

test/common/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ if (exports.isLinux) {
182182
];
183183
}
184184

185-
exports.envPlus = function(additionalEnv) {
186-
return Object.assign({}, process.env, additionalEnv);
187-
};
188-
189185
Object.defineProperty(exports, 'inFreeBSDJail', {
190186
get: function() {
191187
if (inFreeBSDJail !== null) return inFreeBSDJail;

test/parallel/test-benchmark-crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const argv = ['--set', 'algo=sha256',
2727
'--set', 'writes=1',
2828
'crypto'];
2929

30-
const child = fork(runjs, argv, { env: common.envPlus({
30+
const child = fork(runjs, argv, { env: Object.assign({}, process.env, {
3131
NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }) });
3232

3333
child.on('exit', (code, signal) => {

test/parallel/test-benchmark-timers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const common = require('../common');
3+
require('../common');
44

55
// Minimal test for timers benchmarks. This makes sure the benchmarks aren't
66
// horribly broken but nothing more than that.
@@ -15,9 +15,10 @@ const argv = ['--set', 'type=depth',
1515
'--set', 'thousands=0.001',
1616
'timers'];
1717

18-
const child = fork(runjs, argv, { env: common.envPlus({
19-
NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }) });
18+
const env = Object.assign({}, process.env,
19+
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
2020

21+
const child = fork(runjs, argv, { env });
2122
child.on('exit', (code, signal) => {
2223
assert.strictEqual(code, 0);
2324
assert.strictEqual(signal, null);

test/parallel/test-child-process-env.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ Object.setPrototypeOf(env, {
3434

3535
let child;
3636
if (common.isWindows) {
37-
child = spawn('cmd.exe', ['/c', 'set'], common.envPlus({ env: env }));
37+
child = spawn('cmd.exe', ['/c', 'set'],
38+
Object.assign({}, process.env, { env: env }));
3839
} else {
39-
child = spawn('/usr/bin/env', [], common.envPlus({ env: env }));
40+
child = spawn('/usr/bin/env', [],
41+
Object.assign({}, process.env, { env: env }));
4042
}
4143

4244

test/parallel/test-child-process-exec-env.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ function after(err, stdout, stderr) {
4444
if (!common.isWindows) {
4545
child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after);
4646
} else {
47-
child = exec('set', { env: common.envPlus({ 'HELLO': 'WORLD' }) }, after);
47+
child = exec('set',
48+
{ env: Object.assign({}, process.env, { 'HELLO': 'WORLD' }) },
49+
after);
4850
}
4951

5052
child.stdout.setEncoding('utf8');

test/parallel/test-child-process-spawn-shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ command.on('close', common.mustCall((code, signal) => {
5050

5151
// Verify that the environment is properly inherited
5252
const env = cp.spawn(`"${process.execPath}" -pe process.env.BAZ`, {
53-
env: common.envPlus({ BAZ: 'buzz' }),
53+
env: Object.assign({}, process.env, { BAZ: 'buzz' }),
5454
encoding: 'utf8',
5555
shell: true
5656
});

test/parallel/test-child-process-spawnsync-env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
2424
const assert = require('assert');
2525
const cp = require('child_process');
2626

@@ -29,7 +29,7 @@ if (process.argv[2] === 'child') {
2929
} else {
3030
const expected = 'bar';
3131
const child = cp.spawnSync(process.execPath, [__filename, 'child'], {
32-
env: common.envPlus({ foo: expected })
32+
env: Object.assign(process.env, { foo: expected })
3333
});
3434

3535
assert.strictEqual(child.stdout.toString().trim(), expected);

test/parallel/test-child-process-spawnsync-shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ assert.strictEqual(command.stdout.toString().trim(), 'bar');
3737

3838
// Verify that the environment is properly inherited
3939
const env = cp.spawnSync(`"${process.execPath}" -pe process.env.BAZ`, {
40-
env: common.envPlus({ BAZ: 'buzz' }),
40+
env: Object.assign({}, process.env, { BAZ: 'buzz' }),
4141
shell: true
4242
});
4343

test/parallel/test-cli-node-options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ disallow('--');
2929
disallow('--no_warnings'); // Node options don't allow '_' instead of '-'.
3030

3131
function disallow(opt) {
32-
const options = { env: common.envPlus({ NODE_OPTIONS: opt }) };
32+
const options = { env: Object.assign({}, process.env,
33+
{ NODE_OPTIONS: opt }) };
3334
exec(process.execPath, options, common.mustCall(function(err) {
3435
const message = err.message.split(/\r?\n/)[1];
3536
const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
@@ -71,7 +72,7 @@ function expect(opt, want) {
7172
const printB = require.resolve('../fixtures/printB.js');
7273
const argv = [printB];
7374
const opts = {
74-
env: common.envPlus({ NODE_OPTIONS: opt }),
75+
env: Object.assign({}, process.env, { NODE_OPTIONS: opt }),
7576
maxBuffer: 1000000000,
7677
};
7778
exec(process.execPath, argv, opts, common.mustCall(function(err, stdout) {

test/parallel/test-crypto-fips.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ testHelper(
6363
[],
6464
FIPS_DISABLED,
6565
'require("crypto").fips',
66-
common.envPlus({ 'OPENSSL_CONF': '' }));
66+
Object.assign({}, process.env, { 'OPENSSL_CONF': '' }));
6767

6868
// --enable-fips should turn FIPS mode on
6969
testHelper(
@@ -108,23 +108,23 @@ if (!sharedOpenSSL()) {
108108
[],
109109
compiledWithFips() ? FIPS_ENABLED : FIPS_DISABLED,
110110
'require("crypto").fips',
111-
common.envPlus({ 'OPENSSL_CONF': CNF_FIPS_ON }));
111+
Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_ON }));
112112

113113
// --openssl-config option should override OPENSSL_CONF
114114
testHelper(
115115
'stdout',
116116
[`--openssl-config=${CNF_FIPS_ON}`],
117117
compiledWithFips() ? FIPS_ENABLED : FIPS_DISABLED,
118118
'require("crypto").fips',
119-
common.envPlus({ 'OPENSSL_CONF': CNF_FIPS_OFF }));
119+
Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF }));
120120
}
121121

122122
testHelper(
123123
'stdout',
124124
[`--openssl-config=${CNF_FIPS_OFF}`],
125125
FIPS_DISABLED,
126126
'require("crypto").fips',
127-
common.envPlus({ 'OPENSSL_CONF': CNF_FIPS_ON }));
127+
Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_ON }));
128128

129129
// --enable-fips should take precedence over OpenSSL config file
130130
testHelper(
@@ -140,7 +140,7 @@ testHelper(
140140
['--enable-fips'],
141141
compiledWithFips() ? FIPS_ENABLED : OPTION_ERROR_STRING,
142142
'require("crypto").fips',
143-
common.envPlus({ 'OPENSSL_CONF': CNF_FIPS_OFF }));
143+
Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF }));
144144

145145
// --force-fips should take precedence over OpenSSL config file
146146
testHelper(
@@ -156,7 +156,7 @@ testHelper(
156156
['--force-fips'],
157157
compiledWithFips() ? FIPS_ENABLED : OPTION_ERROR_STRING,
158158
'require("crypto").fips',
159-
common.envPlus({ 'OPENSSL_CONF': CNF_FIPS_OFF }));
159+
Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF }));
160160

161161
// setFipsCrypto should be able to turn FIPS mode on
162162
testHelper(

test/parallel/test-fs-readfile-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const fixtures = require('../common/fixtures');
3333
function test(env, cb) {
3434
const filename = fixtures.path('test-fs-readfile-error.js');
3535
const execPath = `"${process.execPath}" "${filename}"`;
36-
const options = { env: common.envPlus(env) };
36+
const options = { env: Object.assign({}, process.env, env) };
3737
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
3838
assert(err);
3939
assert.strictEqual(stdout, '');

test/parallel/test-http-server-stale-close.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
2424
const http = require('http');
2525
const fork = require('child_process').fork;
2626

@@ -44,7 +44,7 @@ if (process.env.NODE_TEST_FORK_PORT) {
4444
});
4545
server.listen(0, function() {
4646
fork(__filename, {
47-
env: common.envPlus({
47+
env: Object.assign({}, process.env, {
4848
NODE_TEST_FORK_PORT: this.address().port
4949
})
5050
});

test/parallel/test-icu-data-dir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const expected =
1717
}
1818

1919
{
20-
const env = common.envPlus({ NODE_ICU_DATA: '/' });
20+
const env = Object.assign({}, process.env, { NODE_ICU_DATA: '/' });
2121
const child = spawnSync(process.execPath, ['-e', '0'], { env });
2222
assert(child.stderr.toString().includes(expected));
2323
}

test/parallel/test-inspector-open.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const url = require('url');
1313
if (process.env.BE_CHILD)
1414
return beChild();
1515

16-
const child = fork(__filename, { env: common.envPlus({ BE_CHILD: 1 }) });
16+
const child = fork(__filename,
17+
{ env: Object.assign({}, process.env, { BE_CHILD: 1 }) });
1718

1819
child.once('message', common.mustCall((msg) => {
1920
assert.strictEqual(msg.cmd, 'started');

test/parallel/test-module-loading-globalpaths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if (process.argv[2] === 'child') {
3636
const testFixturesDir = path.join(common.fixturesDir,
3737
path.basename(__filename, '.js'));
3838

39-
const env = common.envPlus({});
39+
const env = Object.assign({}, process.env);
4040
// Turn on module debug to aid diagnosing failures.
4141
env['NODE_DEBUG'] = 'module';
4242
// Unset NODE_PATH.

test/parallel/test-npm-install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const pkgPath = path.join(installDir, 'package.json');
3939

4040
fs.writeFileSync(pkgPath, pkgContent);
4141

42-
const env = common.envPlus({
42+
const env = Object.assign({}, process.env, {
4343
PATH: path.dirname(process.execPath),
4444
NPM_CONFIG_PREFIX: path.join(npmSandbox, 'npm-prefix'),
4545
NPM_CONFIG_TMP: path.join(npmSandbox, 'npm-tmp'),

test/parallel/test-pending-deprecation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ switch (process.argv[2]) {
3737

3838
// Test the NODE_PENDING_DEPRECATION environment var.
3939
fork(__filename, ['env'], {
40-
env: common.envPlus({ NODE_PENDING_DEPRECATION: 1 }),
40+
env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }),
4141
silent: true
4242
}).on('exit', common.mustCall((code) => {
4343
assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));

test/parallel/test-process-redirect-warnings-env.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ common.refreshTmpDir();
1616
const warnmod = require.resolve(`${common.fixturesDir}/warnings.js`);
1717
const warnpath = path.join(common.tmpDir, 'warnings.txt');
1818

19-
fork(warnmod, { env: common.envPlus({ NODE_REDIRECT_WARNINGS: warnpath }) })
19+
fork(warnmod, { env: Object.assign({}, process.env,
20+
{ NODE_REDIRECT_WARNINGS: warnpath }) })
2021
.on('exit', common.mustCall(() => {
2122
fs.readFile(warnpath, 'utf8', common.mustCall((err, data) => {
2223
assert.ifError(err);

test/parallel/test-repl-envvars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const tests = [
3636
];
3737

3838
function run(test) {
39-
const env = common.envPlus(test.env);
39+
const env = Object.assign({}, process.env, test.env);
4040
const expected = test.expected;
4141
const opts = {
4242
terminal: true,

test/parallel/test-require-symlink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function test() {
6060

6161
// Also verify that symlinks works for setting preserve via env variables
6262
const childEnv = spawn(node, [linkScript], {
63-
env: common.envPlus({ NODE_PRESERVE_SYMLINKS: '1' })
63+
env: Object.assign({}, process.env, { NODE_PRESERVE_SYMLINKS: '1' })
6464
});
6565
childEnv.on('close', function(code, signal) {
6666
assert.strictEqual(code, 0);

test/parallel/test-stdin-script-child.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const assert = require('assert');
55
const { spawn } = require('child_process');
66
for (const args of [[], ['-']]) {
77
const child = spawn(process.execPath, args, {
8-
env: common.envPlus({
8+
env: Object.assign({}, process.env, {
99
NODE_DEBUG: process.argv[2]
1010
})
1111
});

test/parallel/test-tls-env-bad-extra-ca.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const env = Object.assign({}, process.env, {
2121
});
2222

2323
const opts = {
24-
env: common.envPlus(env),
24+
env: env,
2525
silent: true,
2626
};
2727
let stderr = '';

test/parallel/test-tls-env-extra-ca.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const server = tls.createServer(options, common.mustCall(function(s) {
3232
s.end('bye');
3333
server.close();
3434
})).listen(0, common.mustCall(function() {
35-
const env = common.envPlus({
35+
const env = Object.assign({}, process.env, {
3636
CHILD: 'yes',
3737
PORT: this.address().port,
3838
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'ca1-cert.pem')

test/sequential/test-benchmark-http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const path = require('path');
1818

1919
const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');
2020

21-
const env = common.envPlus({ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
21+
const env = Object.assign({}, process.env,
22+
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
2223

2324
const child = fork(runjs, ['--set', 'benchmarker=test-double',
2425
'--set', 'c=1',

0 commit comments

Comments
 (0)