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>
pull/36443/head
Santiago Gimeno 2020-12-03 10:38:28 +01:00 committed by Node.js GitHub Bot
parent 6d3775e291
commit ca8eb795be
1 changed files with 6 additions and 1 deletions

View File

@ -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());
}));
}