Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

child_process: fix test implementation for options.detached

  • Loading branch information...
commit 2eb181d28c71e20307166c06317cdd03d102854c 1 parent 25e8ea1
@AvianFlu AvianFlu authored isaacs committed
View
13 test/fixtures/parent-process-nonpersistent.js
@@ -0,0 +1,13 @@
+
+var spawn = require('child_process').spawn,
+ path = require('path'),
+ childPath = path.join(__dirname, 'child-process-persistent.js');
+
+var child = spawn(process.execPath, [ childPath ], {
+ detached: true,
+ stdio: 'ignore'
+});
+
+console.log(child.pid);
+
+child.unref();
View
19 test/simple/test-child-process-detached.js
@@ -24,15 +24,22 @@ var assert = require('assert');
var path = require('path');
var spawn = require('child_process').spawn;
-var childPath = path.join(__dirname, '..', 'fixtures', 'child-process-persistent.js');
+var childPath = path.join(__dirname, '..', 'fixtures', 'parent-process-nonpersistent.js');
+var persistentPid = -1;
-var child = spawn(process.execPath, [ childPath ], {
- detached: true,
- stdio: 'ignore'
+var child = spawn(process.execPath, [ childPath ]);
+
+child.stdout.on('data', function (data) {
+ persistentPid = parseInt(data, 10);
});
process.on('exit', function () {
- process.kill(child.pid);
- assert.throws(process.kill(child.pid), Error);
+ assert(persistentPid !== -1);
+ assert.throws(function () {
+ process.kill(child.pid);
+ });
+ assert.doesNotThrow(function () {
+ process.kill(persistentPid);
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.