0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-fork-close.js
Sakthipriyan Vairamani 612307564b test: make import common as the first line
The `test/common` module has the capability to identify if any variable
is leaked to the global scope and fail the test. So that has to be
imported at the beginning.

PR-URL: https://github.com/nodejs/node/pull/7786
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-07-21 16:39:21 -07:00

31 lines
675 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');
let gotMessage = false;
let gotExit = false;
let gotClose = false;
cp.on('message', common.mustCall(function(message) {
assert(!gotMessage);
assert(!gotClose);
assert.strictEqual(message, 'hello');
gotMessage = true;
}));
cp.on('exit', common.mustCall(function() {
assert(!gotExit);
assert(!gotClose);
gotExit = true;
}));
cp.on('close', common.mustCall(function() {
assert(gotMessage);
assert(gotExit);
assert(!gotClose);
gotClose = true;
}));