From ae18a90f7e251854b965120faded1856946c60b4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 5 Sep 2013 09:21:39 +0800 Subject: [PATCH] Add test case for #83. --- spec/fixtures/module/fork_ping.js | 11 +++++++++++ spec/node/child_process.coffee | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/fixtures/module/fork_ping.js diff --git a/spec/fixtures/module/fork_ping.js b/spec/fixtures/module/fork_ping.js new file mode 100644 index 0000000..e6d3f92 --- /dev/null +++ b/spec/fixtures/module/fork_ping.js @@ -0,0 +1,11 @@ +process.on('uncaughtException', function(error) { + process.send(error.stack); +}); + +var child = require('child_process').fork(__dirname + '/ping.js'); +process.on('message', function(msg) { + child.send(msg); +}); +child.on('message', function (msg) { + process.send(msg); +}); diff --git a/spec/node/child_process.coffee b/spec/node/child_process.coffee index 2246391..fdffb10 100644 --- a/spec/node/child_process.coffee +++ b/spec/node/child_process.coffee @@ -12,3 +12,10 @@ describe 'child_process', -> assert.equal msg, 'message' done() child.send 'message' + + it 'should work in forked process', (done) -> + child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js') + child.on 'message', (msg) -> + assert.equal msg, 'message' + done() + child.send 'message' -- 2.7.4