Skip to content

Commit

Permalink
test: use portable EOL
Browse files Browse the repository at this point in the history
The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

PR-URL: #32104
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
HarshithaKP authored and MylesBorins committed Mar 24, 2020
1 parent e83dcde commit c0af3ac
Showing 1 changed file with 5 additions and 3 deletions.
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());
}));
}

0 comments on commit c0af3ac

Please sign in to comment.