Skip to content

test: improve child_process test coverage #11278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/parallel/test-child-process-ignore-stdio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
const common = require('../common');

const assert = require('assert');
const fork = require('child_process').fork;

const childScript = `${common.fixturesDir}/child-process-spawn-node`;
const payload = {hello: 'world'};
const stringOpts = {stdio: 'ignore'};

const child = fork(childScript, stringOpts);

child.on('message', (message) => {
assert.deepStrictEqual(message, {foo: 'bar'});
});

child.send(payload);

child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
3 changes: 3 additions & 0 deletions test/parallel/test-child-process-spawn-typeerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ assert.throws(function() {

// Argument types for combinatorics
const a = [];
const attr = ['foo'];
const o = {};
const c = function c() {};
const s = 'string';
Expand Down Expand Up @@ -153,6 +154,8 @@ assert.throws(function() { execFile(cmd, u, o, s); }, TypeError);
assert.throws(function() { execFile(cmd, n, o, s); }, TypeError);
assert.doesNotThrow(function() { execFile(cmd, c, s); });

// Check arguments array is not empty for execFile
assert.doesNotThrow(function() { execFile(cmd, attr, o, c); });

// verify that fork has same argument parsing behaviour as spawn
//
Expand Down