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: #25988

PR-URL: #37632
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
Trott authored and targos committed May 1, 2021
1 parent 376fcc7 commit 27d4fed
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 27d4fed

Please sign in to comment.