node/test/parallel/test-process-argv-0.js
Rich Trott 972a57cb20 test: make test-process-argv-0 robust
Remove use of STDERR to avoid test flakiness on CentOS 5.

Use parent process exit event for assertion rather than child exit
event.

PR-URL: https://github.com/nodejs/node/pull/2541
Fixes: https://github.com/nodejs/node/issues/2477
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-08-26 09:09:56 -07:00

22 lines
502 B
JavaScript

'use strict';
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
if (process.argv[2] !== 'child') {
var child = spawn(process.execPath, [__filename, 'child'], {
cwd: path.dirname(process.execPath)
});
var childArgv0 = '';
child.stdout.on('data', function(chunk) {
childArgv0 += chunk;
});
process.on('exit', function() {
assert.equal(childArgv0, process.execPath);
});
}
else {
process.stdout.write(process.argv[0]);
}