Skip to content

Commit fdf73b1

Browse files
BethGriggsMylesBorins
authored andcommitted
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: #18883 PR-URL: #14822 Refs: #13390 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d333ba5 commit fdf73b1

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

‎test/parallel/test-env-var-no-warnings.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const cp = require('child_process');
66
if(process.argv[2]==='child'){
77
process.emitWarning('foo');
88
}else{
9-
functiontest(env){
9+
functiontest(newEnv){
10+
constenv=Object.assign({},process.env,newEnv);
1011
constcmd=`"${process.execPath}" "${__filename}" child`;
1112

1213
cp.exec(cmd,{ env },common.mustCall((err,stdout,stderr)=>{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ if (process.env.CHILD){
1616
returntls.createServer({});
1717
}
1818

19-
constenv={
19+
constenv=Object.assign({},process.env,{
2020
CHILD: 'yes',
21-
NODE_EXTRA_CA_CERTS: `${fixtures.fixturesDir}/no-such-file-exists`
22-
};
21+
NODE_EXTRA_CA_CERTS: `${fixtures.fixturesDir}/no-such-file-exists`,
22+
});
2323

2424
constopts={
2525
env: env,

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

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

4141
fork(__filename,{env: env}).on('exit',common.mustCall(function(status){
4242
assert.strictEqual(status,0,'client did not succeed in connecting');

0 commit comments

Comments
(0)