2010-12-05 20:15:30 +01:00
|
|
|
var common = require('../common');
|
2010-12-05 00:20:34 +01:00
|
|
|
var assert = require('assert');
|
2010-03-17 22:00:17 +01:00
|
|
|
|
|
|
|
var spawn = require('child_process').spawn;
|
2011-02-18 22:44:20 +01:00
|
|
|
|
2011-08-01 22:43:38 +02:00
|
|
|
var isWindows = process.platform === 'win32';
|
|
|
|
|
2011-02-18 22:44:20 +01:00
|
|
|
var env = {
|
|
|
|
'HELLO': 'WORLD'
|
|
|
|
};
|
|
|
|
env.__proto__ = {
|
|
|
|
'FOO': 'BAR'
|
2011-10-05 00:08:18 +02:00
|
|
|
};
|
2011-02-18 22:44:20 +01:00
|
|
|
|
2011-08-01 22:43:38 +02:00
|
|
|
if (isWindows) {
|
2011-08-02 02:18:01 +02:00
|
|
|
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
|
2011-08-01 22:43:38 +02:00
|
|
|
} else {
|
|
|
|
var child = spawn('/usr/bin/env', [], {env: env});
|
|
|
|
}
|
|
|
|
|
2010-03-17 22:00:17 +01:00
|
|
|
|
2010-12-05 20:15:30 +01:00
|
|
|
var response = '';
|
2010-03-03 19:45:58 +01:00
|
|
|
|
2010-03-17 22:00:17 +01:00
|
|
|
child.stdout.setEncoding('utf8');
|
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
child.stdout.on('data', function(chunk) {
|
2010-12-05 20:15:30 +01:00
|
|
|
console.log('stdout: ' + chunk);
|
2010-03-17 22:00:17 +01:00
|
|
|
response += chunk;
|
2010-03-03 19:45:58 +01:00
|
|
|
});
|
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
process.on('exit', function() {
|
2010-12-05 20:15:30 +01:00
|
|
|
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
|
2011-02-18 22:44:20 +01:00
|
|
|
assert.ok(response.indexOf('FOO=BAR') >= 0);
|
2010-03-03 19:45:58 +01:00
|
|
|
});
|