Skip to content

Commit 65b5ccc

Browse files
mscdexMyles Borins
authored and
Myles Borins
committed
test: fix spawn on windows
Most Windows systems do not have an external `echo` program installed, so any attempts to spawn `echo` as a child process will fail with `ENOENT`. This commit forces the use of the built-in `echo` provided by `cmd.exe`. PR-URL: #7049 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: João Reis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 96ed883 commit 65b5ccc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/parallel/test-child-process-flush-stdio.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const cp = require('child_process');
33
const common = require('../common');
44
const assert = require('assert');
55

6-
const p = cp.spawn('echo');
6+
// Windows' `echo` command is a built-in shell command and not an external
7+
// executable like on *nix
8+
const opts = { shell: common.isWindows };
9+
10+
const p = cp.spawn('echo', [], opts);
711

812
p.on('close', common.mustCall(function(code, signal) {
913
assert.strictEqual(code, 0);
@@ -15,7 +19,7 @@ p.stdout.read();
1519

1620
function spawnWithReadable() {
1721
const buffer = [];
18-
const p = cp.spawn('echo', ['123']);
22+
const p = cp.spawn('echo', ['123'], opts);
1923
p.on('close', common.mustCall(function(code, signal) {
2024
assert.strictEqual(code, 0);
2125
assert.strictEqual(signal, null);

0 commit comments

Comments
 (0)