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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
b170fb7c55
commit
78cdd4baa4
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user