Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Add isolate version of test-child-process-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Dec 28, 2011
1 parent 036e593 commit b319699
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/child_process.js
Expand Up @@ -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()');
}
Expand Down
8 changes: 7 additions & 1 deletion test/simple/test-child-process-fork.js
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions 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);

0 comments on commit b319699

Please sign in to comment.