Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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]);
Expand Down Expand Up @@ -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());
}));
}