Skip to content

Commit 776905e

Browse files
HarshithaKPtargos
authored andcommittedApr 22, 2020
test: use portable EOL
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>
1 parent 76e2455 commit 776905e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎test/parallel/test-child-process-pipe-dataflow.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const common = require('../common');
33
const assert = require('assert');
44
const path = require('path');
55
const fs = require('fs');
6+
const os = require('os');
67
const spawn = require('child_process').spawn;
78
const tmpdir = require('../common/tmpdir');
89

@@ -25,8 +26,8 @@ const MB = KB * KB;
2526
// meanings to new line - for example, line buffering.
2627
// So cut the buffer into lines at some points, forcing
2728
// data flow to be split in the stream.
28-
for (let i = 0; i < KB; i++)
29-
buf[i * KB] = 10;
29+
for (let i = 1; i < KB; i++)
30+
buf.write(os.EOL, i * KB);
3031
fs.writeFileSync(file, buf.toString());
3132

3233
cat = spawn('cat', [file]);
@@ -61,6 +62,7 @@ const MB = KB * KB;
6162
});
6263

6364
wc.stdout.on('data', common.mustCall((data) => {
64-
assert.strictEqual(data.toString().trim(), MB.toString());
65+
// Grep always adds one extra byte at the end.
66+
assert.strictEqual(data.toString().trim(), (MB + 1).toString());
6567
}));
6668
}

0 commit comments

Comments
 (0)
Please sign in to comment.