From 7f54dd4f0704c73f48a2377e16a8e537a83b45da Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 6 Mar 2021 06:09:12 -0800 Subject: [PATCH] test: improve error reporting in test-child-process-pipe-dataflow 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: https://github.com/nodejs/node/issues/25988 PR-URL: https://github.com/nodejs/node/pull/37632 Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig --- test/parallel/test-child-process-pipe-dataflow.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index 31846c8a715c4c..2e2edc65e9e0d5 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -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()); - })); + }); }