Skip to content

Commit

Permalink
test: deflake child-process-pipe-dataflow
Browse files Browse the repository at this point in the history
Fixes: #25988

PR-URL: #40838
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
lpinca authored and BethGriggs committed Nov 29, 2021
1 parent 480f0e1 commit 01ffe03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 @@ -22,12 +21,13 @@ const MB = KB * KB;
const file = path.resolve(tmpdir.path, 'data.txt');
const 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.
// 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. Do not use os.EOL for \n as
// that is 2 characters on Windows and is sometimes converted to 1 character
// which causes the test to fail.
for (let i = 1; i < KB; i++)
buf.write(os.EOL, i * KB);
buf.write('\n', i * KB);
fs.writeFileSync(file, buf.toString());

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

0 comments on commit 01ffe03

Please sign in to comment.