Skip to content
Permalink
Browse files

test: include all stdio strings for fork()

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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information...
Trott committed Mar 10, 2017
1 parent b170fb7 commit 78cdd4baa41af8a51146dcda3d1932c0011a8a78
Showing with 10 additions and 7 deletions.
  1. +10 −7 test/parallel/test-child-process-fork-stdio-string-variant.js
@@ -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.
You can’t perform that action at this time.