From f07cdd2cc7317a47870b3b15f1c3298a32883487 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 3 Dec 2020 10:38:28 +0100 Subject: [PATCH] test: fix child-process-pipe-dataflow Make sure all the `wc` process stdout data is received before checking its validity. Fixes: https://github.com/nodejs/node/issues/25988 --- test/parallel/test-child-process-pipe-dataflow.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index 5f425a6f3d087c..31846c8a715c4c 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -61,8 +61,13 @@ const MB = KB * KB; })); }); + let wcBuf = ''; wc.stdout.on('data', common.mustCall((data) => { + wcBuf += data; + })); + + wc.on('close', common.mustCall(() => { // Grep always adds one extra byte at the end. - assert.strictEqual(data.toString().trim(), (MB + 1).toString()); + assert.strictEqual(wcBuf.trim(), (MB + 1).toString()); })); }