mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
762 B
42 lines
762 B
12 years ago
|
|
||
|
require('../index');
|
||
|
|
||
|
var assert = require('assert'),
|
||
|
fork = require('child_process').fork;
|
||
|
|
||
|
var cp = fork('worker-fork');
|
||
|
|
||
|
var gotMessage = false,
|
||
|
gotExit = false,
|
||
|
gotClose = false;
|
||
|
|
||
|
cp.on('message', function(msg) {
|
||
|
assert.strictEqual(msg, 'hello');
|
||
|
assert(!gotMessage);
|
||
|
assert(!gotClose);
|
||
|
gotMessage = true;
|
||
|
});
|
||
|
|
||
|
cp.on('exit', function(code, signal) {
|
||
|
assert.strictEqual(code, 0);
|
||
|
assert(!signal);
|
||
|
assert(!gotExit);
|
||
|
assert(!gotClose);
|
||
|
gotExit = true;
|
||
|
});
|
||
|
|
||
|
cp.on('close', function(code, signal) {
|
||
|
assert.strictEqual(code, 0);
|
||
|
assert(!signal);
|
||
|
assert(gotExit);
|
||
|
assert(gotMessage);
|
||
|
assert(!gotClose);
|
||
|
gotClose = true;
|
||
|
});
|
||
|
|
||
|
process.on('exit', function() {
|
||
|
assert(gotMessage);
|
||
|
assert(gotExit);
|
||
|
assert(gotClose);
|
||
|
});
|