test: preserve process.env in forked child_process
authorStanislav Ochotnicky <sochotnicky@redhat.com>
Wed, 10 Apr 2013 13:38:02 +0000 (15:38 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 16 Apr 2013 15:05:51 +0000 (17:05 +0200)
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve
it for forked process. There are possibly other environment variables
that could cause test failures so we preserve whole environment of
parent process.

test/simple/test-child-process-fork-exec-path.js

index 51370d7d59fedf5056e19178ea46e649b4fe917f..e0cf77c28eb98baa3ab44174eea38396fa9a5b3d 100755 (executable)
@@ -44,9 +44,12 @@ else {
   fs.writeFileSync(copyPath, fs.readFileSync(nodePath));
   fs.chmodSync(copyPath, '0755');
 
+  // slow but simple
+  var envCopy = JSON.parse(JSON.stringify(process.env));
+  envCopy.FORK = 'true';
   var child = require('child_process').fork(__filename, {
     execPath: copyPath,
-    env: { FORK: 'true' }
+    env: envCopy
   });
   child.on('message', common.mustCall(function(recv) {
     assert.deepEqual(msg, recv);