0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-constructor.js
Evan Lucas a77c330c32 child_process: expose ChildProcess constructor
Creates two new internal modules (child_process and socket_list) for
better readability.

Exposes the ChildProcess constructor from the child_process module so
one can now `require(‘child_process’).ChildProcess`

Fixes: https://github.com/nodejs/io.js/issues/1751
PR-URL: https://github.com/nodejs/io.js/pull/1760
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-05-28 09:38:29 -05:00

26 lines
591 B
JavaScript

'use strict';
var assert = require('assert');
var common = require('../common');
var child_process = require('child_process');
var ChildProcess = child_process.ChildProcess;
assert.equal(typeof ChildProcess, 'function');
// test that we can call spawn
var child = new ChildProcess();
child.spawn({
file: process.execPath,
args: ['--interactive'],
cwd: process.cwd(),
stdio: 'pipe'
});
assert.equal(child.hasOwnProperty('pid'), true);
// try killing with invalid signal
assert.throws(function() {
child.kill('foo');
}, /Unknown signal: foo/);
assert.equal(child.kill(), true);