0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-pipe-head.js
Antoine du Hamel 1fcb128771
test: do not assume process.execPath contains no spaces
We had a bunch of tests that would fail if run from an executable that
contains any char that should be escaped when run from a shell.

PR-URL: https://github.com/nodejs/node/pull/55028
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-09-22 13:03:30 +00:00

18 lines
583 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const exec = require('child_process').exec;
const script = fixtures.path('print-10-lines.js');
const cmd = `"${common.isWindows ? process.execPath : '$NODE'}" "${common.isWindows ? script : '$FILE'}" | head -2`;
exec(cmd, {
env: common.isWindows ? process.env : { ...process.env, NODE: process.execPath, FILE: script },
}, common.mustSucceed((stdout, stderr) => {
const lines = stdout.split('\n');
assert.strictEqual(lines.length, 3);
}));