diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index bc5e4e02fdf4e9..5f425a6f3d087c 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); const path = require('path'); const fs = require('fs'); +const os = require('os'); const spawn = require('child_process').spawn; const tmpdir = require('../common/tmpdir'); @@ -25,8 +26,8 @@ const MB = KB * KB; // meanings to new line - for example, line buffering. // So cut the buffer into lines at some points, forcing // data flow to be split in the stream. - for (let i = 0; i < KB; i++) - buf[i * KB] = 10; + for (let i = 1; i < KB; i++) + buf.write(os.EOL, i * KB); fs.writeFileSync(file, buf.toString()); cat = spawn('cat', [file]); @@ -61,6 +62,7 @@ const MB = KB * KB; }); wc.stdout.on('data', common.mustCall((data) => { - assert.strictEqual(data.toString().trim(), MB.toString()); + // Grep always adds one extra byte at the end. + assert.strictEqual(data.toString().trim(), (MB + 1).toString()); })); }