From 4fedb702b221469a65f0f2bc267ae08c8159e72a Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Thu, 5 Mar 2020 09:28:31 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/25988 PR-URL: https://github.com/nodejs/node/pull/32104 Reviewed-By: Gireesh Punathil Reviewed-By: Anna Henningsen --- test/parallel/test-child-process-pipe-dataflow.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index bc5e4e02fdf4e9..5f425a6f3d087c 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -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'); @@ -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]); @@ -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()); })); }