Browse Source

Add isolate version of test-child-process-fork

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
b319699132
  1. 6
      lib/child_process.js
  2. 8
      test/simple/test-child-process-fork.js
  3. 13
      test/simple/test-isolates2.js

6
lib/child_process.js

@ -153,6 +153,12 @@ exports.fork = function(modulePath, args, options) {
args = args ? args.slice(0) : [];
args.unshift(modulePath);
if (options.thread) {
if (!process.features.isolates) {
throw new Error('node compiled without isolate support');
}
}
if (options.stdinStream) {
throw new Error('stdinStream not allowed for fork()');
}

8
test/simple/test-child-process-fork.js

@ -24,7 +24,13 @@ var common = require('../common');
var fork = require('child_process').fork;
var args = ['foo', 'bar'];
var n = fork(common.fixturesDir + '/child-process-spawn-node.js', args);
var options = {
thread: process.TEST_ISOLATE ? true : false
};
var n = fork(common.fixturesDir + '/child-process-spawn-node.js',
args,
options);
assert.deepEqual(args, ['foo', 'bar']);
var messageCount = 0;

13
test/simple/test-isolates2.js

@ -0,0 +1,13 @@
// Skip this test if Node is not compiled with isolates support.
if (!process.features.isolates) return;
var assert = require('assert');
// This is the same test as test-child-process-fork except it uses isolates
// instead of processes. process.TEST_ISOLATE is a ghetto method of passing
// some information into the other test.
process.TEST_ISOLATE = true;
require('./test-child-process-fork');
var numThreads = process.binding('isolates').count();
assert.ok(numThreads > 1);
Loading…
Cancel
Save