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