Skip to content
Closed
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
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.
  • Loading branch information
Trott committed Mar 10, 2017
commit 92a1f95c83218b23df43a8a9aef0d4f62ba9818c
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);