Skip to content

Commit

Permalink
test: improve error reporting in test-child-process-pipe-dataflow
Browse files Browse the repository at this point in the history
When the test fails, it usually ends up failing on the assertion that
`wc` did not find as many bytes as it expected. That may not be
helpful if it is caused by a failure earlier in the command
pipeline ( cat | grep | wc ). Move the byte check to
`process.on('exit')` so that other error handlers that report the
existence of errors run first.

Refs: nodejs#25988

PR-URL: nodejs#37632
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Trott committed Mar 9, 2021
1 parent 4947ce5 commit 7f54dd4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const MB = KB * KB;
wcBuf += data;
}));

wc.on('close', common.mustCall(() => {
process.on('exit', () => {
// Grep always adds one extra byte at the end.
assert.strictEqual(wcBuf.trim(), (MB + 1).toString());
}));
});
}

0 comments on commit 7f54dd4

Please sign in to comment.