From 0e821ff3379477e652989fea7192cc33850116f9 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 PR-URL: https://github.com/nodejs/node/pull/36366 Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: James M Snell --- 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()); })); }