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 <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Santiago Gimeno authored and Node.js GitHub Bot committed 2020-12-08 05:23:36 +00:00
1 parent 6d3775e291
commit ca8eb795be
1 file changed
+6 -1
@@ -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());
}));
}