Skip to content
Closed
Changes from 1 commit
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
Next Next commit
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
  • Loading branch information
HarshithaKP committed Mar 5, 2020
commit 9cdc6b67412134e9d226d18cdb41cb4aba0e348b
6 changes: 4 additions & 2 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 @@ -19,14 +20,15 @@ const MB = KB * KB;
{
tmpdir.refresh();
const file = path.resolve(tmpdir.path, 'data.txt');
const buf = Buffer.alloc(MB).fill('x');
let buf = Buffer.alloc(MB).fill('x');

// Most OS commands that deal with data, attach special
// 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.
const eol_len = os.EOL.length;
for (let i = 0; i < KB; i++)
buf[i * KB] = 10;
buf = buf.fill(os.EOL, i * KB, (i * KB + eol_len));
fs.writeFileSync(file, buf.toString());

cat = spawn('cat', [file]);
Expand Down