Permalink
Browse files

[test] Add test for new stdio config.

  • Loading branch information...
AvianFlu committed Aug 1, 2012
1 parent c545005 commit 006e2040b636fe77db49997f7877343fa6d9aa8f
Showing with 28 additions and 2 deletions.
  1. +4 −0 test/fixtures/fork.js
  2. +24 −2 test/monitor/fork-test.js
View
@@ -0,0 +1,4 @@
+if (process.send) {
+ process.send({from: 'child'});
+ process.disconnect();
+}
View
@@ -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));
@@ -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.