Skip to content

Commit

Permalink
test: include all stdio strings for fork()
Browse files Browse the repository at this point in the history
test-child-process-fork-stdio-string-variant was only testing 'pipe' for
its `stdio` value. Add `inherit` and `ignore`.

Also added a `common.mustCall()` to verify that the `message` event is
triggered.

PR-URL: #11783
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
Trott committed Mar 13, 2017
1 parent b170fb7 commit 78cdd4b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/parallel/test-child-process-fork-stdio-string-variant.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ const childScript = `${common.fixturesDir}/child-process-spawn-node`;
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
const malFormedOpts = {stdio: '33'};
const payload = {hello: 'world'};
const stringOpts = {stdio: 'pipe'};

assert.throws(() => fork(childScript, malFormedOpts), errorRegexp);

const child = fork(childScript, stringOpts);
function test(stringVariant) {
const child = fork(childScript, {stdio: stringVariant});

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

child.send(payload);
child.send(payload);

child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
}

['pipe', 'inherit', 'ignore'].forEach(test);

0 comments on commit 78cdd4b

Please sign in to comment.