Skip to content

Commit

Permalink
test: fix child-process-pipe-dataflow
Browse files Browse the repository at this point in the history
Make sure all the `wc` process stdout data is received before checking
its validity.

Fixes: nodejs#25988

PR-URL: nodejs#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>
  • Loading branch information
santigimeno authored and nodejs-github-bot committed Dec 8, 2020
1 parent 6d3775e commit ca8eb79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}));
}

0 comments on commit ca8eb79

Please sign in to comment.