common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. The main tradeoff for this bit of code churn is that it gets the code base most of the way to being able to enable the no-unused-vars rule in eslint. (The non-tooling benefit is that it lessens cognitive load when reading tests as it is an immediate indication that none of the functions or properties in common.js will be used by the test.) PR-URL: https://github.com/nodejs/node/pull/4563 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
44 lines
1 KiB
JavaScript
44 lines
1 KiB
JavaScript
'use strict';
|
|
// Open a chain of five Node processes each a child of the next. The final
|
|
// process exits immediately. Each process in the chain is instructed to
|
|
// exit when its child exits.
|
|
// https://github.com/joyent/node/issues/1726
|
|
|
|
require('../common');
|
|
var assert = require('assert');
|
|
var ch = require('child_process');
|
|
|
|
var gen = +(process.argv[2] || 0);
|
|
var maxGen = 5;
|
|
|
|
|
|
if (gen === maxGen) {
|
|
console.error('hit maxGen, exiting', maxGen);
|
|
return;
|
|
}
|
|
|
|
var child = ch.spawn(process.execPath, [__filename, gen + 1], {
|
|
stdio: [ 'ignore', 'pipe', 'ignore' ]
|
|
});
|
|
assert.ok(!child.stdin);
|
|
assert.ok(child.stdout);
|
|
assert.ok(!child.stderr);
|
|
|
|
console.error('gen=%d, pid=%d', gen, process.pid);
|
|
|
|
/*
|
|
var timer = setTimeout(function() {
|
|
throw new Error('timeout! gen='+gen);
|
|
}, 1000);
|
|
*/
|
|
|
|
child.on('exit', function(code) {
|
|
console.error('exit %d from gen %d', code, gen + 1);
|
|
//clearTimeout(timer);
|
|
});
|
|
|
|
child.stdout.pipe(process.stdout);
|
|
|
|
child.stdout.on('close', function() {
|
|
console.error('child.stdout close gen=%d', gen);
|
|
});
|