Skip to content

Commit c55ad84

Browse files
author
Stewart X Addison
committed
test: fix test-child-process-flush-stdio on win
This test cases tries to use the V6 "shell:true" option on child_process.spawn that isn't in V4, therefore the test failes when there is no "echo.exe" on Windows systems. This fix implements the same functionality (cmd/c echo) that the shell:true option would have given.
1 parent f5c57c7 commit c55ad84

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ const common = require('../common');
44
const assert = require('assert');
55

66
// 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);
7+
// executable like on *nix. The V4 API does not have the "shell" option to
8+
// spawn that we use in V4 and later so we can't use that here.
9+
var p;
10+
if (common.isWindows) {
11+
p = cp.spawn('cmd.exe', ['/c', 'echo'], {});
12+
} else {
13+
p = cp.spawn('echo', [], {});
14+
}
1115

1216
p.on('close', common.mustCall(function(code, signal) {
1317
assert.strictEqual(code, 0);
@@ -19,7 +23,12 @@ p.stdout.read();
1923

2024
function spawnWithReadable() {
2125
const buffer = [];
22-
const p = cp.spawn('echo', ['123'], opts);
26+
var p;
27+
if (common.isWindows) {
28+
p = cp.spawn('cmd.exe', ['/c', 'echo', '123'], {});
29+
} else {
30+
p = cp.spawn('echo', ['123'], {});
31+
}
2332
p.on('close', common.mustCall(function(code, signal) {
2433
assert.strictEqual(code, 0);
2534
assert.strictEqual(signal, null);

0 commit comments

Comments
 (0)