Skip to content

Commit

Permalink
test: increase debugging information in subprocess test
Browse files Browse the repository at this point in the history
Refs: #25988 (comment)

PR-URL: #30761
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Trott authored and targos committed Dec 9, 2019
1 parent d3f0dd2 commit 54a266c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const MB = KB * KB;
cat.stdout._handle.readStart = common.mustNotCall();
grep.stdout._handle.readStart = common.mustNotCall();

// Keep an array of error codes and assert on them during process exit. This
// is because stdio can still be open when a child process exits, and we don't
// want to lose information about what caused the error.
const errors = [];
process.on('exit', () => {
assert.deepStrictEqual(errors, []);
});

[cat, grep, wc].forEach((child, index) => {
const errorHandler = (thing, type) => {
// Don't want to assert here, as we might miss error code info.
Expand All @@ -46,7 +54,9 @@ const MB = KB * KB;
child.stderr.on('data', (d) => { errorHandler(d, 'data'); });
child.on('error', (err) => { errorHandler(err, 'error'); });
child.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, `child ${index} exited with code ${code}`);
if (code !== 0) {
errors.push(`child ${index} exited with code ${code}`);
}
}));
});

Expand Down

0 comments on commit 54a266c

Please sign in to comment.