Files
node/test/parallel/test-child-process-fork-ref2.js
Rich Trott 8b161e0a78 test: check number of message events
When a no-op message event handler is used in a test, make it clear what
is expected by using `common.mustCall()` and `common.mustNotCall()`.

PR-URL: https://github.com/nodejs/node/pull/13125
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <mhdawson@ibm.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-08-15 20:57:22 -07:00

25 lines
558 B
JavaScript

'use strict';
const common = require('../common');
const fork = require('child_process').fork;
if (process.argv[2] === 'child') {
console.log('child -> call disconnect');
process.disconnect();
setTimeout(function() {
console.log('child -> will this keep it alive?');
process.on('message', common.mustNotCall());
}, 400);
} else {
const child = fork(__filename, ['child']);
child.on('disconnect', function() {
console.log('parent -> disconnect');
});
child.once('exit', function() {
console.log('parent -> exit');
});
}