Skip to content

Commit

Permalink
[test] Add test for new stdio config.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu committed Aug 1, 2012
1 parent c545005 commit 006e204
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions test/fixtures/fork.js
@@ -0,0 +1,4 @@
if (process.send) {
process.send({from: 'child'});
process.disconnect();
}
26 changes: 24 additions & 2 deletions test/monitor/fork-test.js
Expand Up @@ -14,9 +14,9 @@ var assert = require('assert'),
vows.describe('forever-monitor/monitor/fork').addBatch({
"When using forever-monitor": {
"and spawning a script that uses `process.send()`": {
"using the 'native' fork": {
"using the 'native' fork with default stdio": {
topic: function () {
var script = path.join(__dirname, '..', '..', 'examples', 'process-send.js'),
var script = path.join(__dirname, '..', 'fixtures', 'fork.js'),
child = new (fmonitor.Monitor)(script, { silent: false, minUptime: 2000, max: 1, fork: true });

child.on('message', this.callback.bind(null, null));
Expand All @@ -29,4 +29,26 @@ vows.describe('forever-monitor/monitor/fork').addBatch({
}
}
}
}).addBatch({
"when spawning a script that uses `process.send()`": {
"using custom stdio and setting IPC to fd 0": {
topic: function () {
var script = path.join(__dirname, '..', 'fixtures', 'fork.js'),
child = new (fmonitor.Monitor)(script, {
silent: false,
minUptime: 2000,
max: 1,
fork: true,
stdio: ['ipc', 'pipe', 'pipe']
});

child.on('message', this.callback.bind(null, null));
child.start();
},
"should reemit the message correctly": function (err, msg) {
assert.isObject(msg);
assert.deepEqual(msg, { from: 'child' });
}
}
}
}).export(module);

0 comments on commit 006e204

Please sign in to comment.