Skip to content

Commit 78cdd4b

Browse files
committed
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent b170fb7 commit 78cdd4b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/parallel/test-child-process-fork-stdio-string-variant.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ const childScript = `${common.fixturesDir}/child-process-spawn-node`;
1212
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
1313
const malFormedOpts = {stdio: '33'};
1414
const payload = {hello: 'world'};
15-
const stringOpts = {stdio: 'pipe'};
1615

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

19-
const child = fork(childScript, stringOpts);
18+
function test(stringVariant) {
19+
const child = fork(childScript, {stdio: stringVariant});
2020

21-
child.on('message', (message) => {
22-
assert.deepStrictEqual(message, {foo: 'bar'});
23-
});
21+
child.on('message', common.mustCall((message) => {
22+
assert.deepStrictEqual(message, {foo: 'bar'});
23+
}));
2424

25-
child.send(payload);
25+
child.send(payload);
2626

27-
child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
27+
child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));
28+
}
29+
30+
['pipe', 'inherit', 'ignore'].forEach(test);

0 commit comments

Comments
 (0)