Skip to content

Commit 7592615

Browse files
Stanislav Ochotnickybnoordhuis
authored andcommitted
test: preserve process.env after test-init exec
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve it for child processes. To be sure we preserve whole environment of parent process and just add TEST_INIT variable to it.
1 parent 47198af commit 7592615

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

test/simple/test-init.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@
3434
// being in the test folder
3535
process.chdir(__dirname);
3636

37-
child.exec(process.execPath + ' test-init', {env: {'TEST_INIT': 1}},
37+
// slow but simple
38+
var envCopy = JSON.parse(JSON.stringify(process.env));
39+
envCopy.TEST_INIT = 1;
40+
41+
child.exec(process.execPath + ' test-init', {env: envCopy},
3842
function(err, stdout, stderr) {
3943
assert.equal(stdout, 'Loaded successfully!',
4044
'`node test-init` failed!');
4145
});
42-
child.exec(process.execPath + ' test-init.js', {env: {'TEST_INIT': 1}},
46+
child.exec(process.execPath + ' test-init.js', {env: envCopy},
4347
function(err, stdout, stderr) {
4448
assert.equal(stdout, 'Loaded successfully!',
4549
'`node test-init.js` failed!');
@@ -48,7 +52,7 @@
4852
// test-init-index is in fixtures dir as requested by ry, so go there
4953
process.chdir(common.fixturesDir);
5054

51-
child.exec(process.execPath + ' test-init-index', {env: {'TEST_INIT': 1}},
55+
child.exec(process.execPath + ' test-init-index', {env: envCopy},
5256
function(err, stdout, stderr) {
5357
assert.equal(stdout, 'Loaded successfully!',
5458
'`node test-init-index failed!');
@@ -59,7 +63,7 @@
5963
// expected in node
6064
process.chdir(common.fixturesDir + '/test-init-native/');
6165

62-
child.exec(process.execPath + ' fs', {env: {'TEST_INIT': 1}},
66+
child.exec(process.execPath + ' fs', {env: envCopy},
6367
function(err, stdout, stderr) {
6468
assert.equal(stdout, 'fs loaded successfully',
6569
'`node fs` failed!');

0 commit comments

Comments
 (0)