node/test/parallel/test-child-process-default-options.js
Rich Trott 185f8497e5 test: scope redeclared vars in test-child-process*
A handful of child process tests had variables declared multiple times
in the same scope using `var`. This change scopes those declarations.

PR-URL: https://github.com/nodejs/node/pull/4944
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2016-01-31 18:06:26 -08:00

29 lines
593 B
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
process.env.HELLO = 'WORLD';
var child;
if (common.isWindows) {
child = spawn('cmd.exe', ['/c', 'set'], {});
} else {
child = spawn('/usr/bin/env', [], {});
}
var response = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
response += chunk;
});
process.on('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0,
'spawn did not use process.env as default');
});