Skip to content

Commit

Permalink
test: fix spawn on windows
Browse files Browse the repository at this point in the history
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 <cjihrig@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
mscdex authored and evanlucas committed Jun 15, 2016
1 parent c2aba5b commit d54c7c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/parallel/test-child-process-flush-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const cp = require('child_process');
const common = require('../common');
const assert = require('assert');

const p = cp.spawn('echo');
// Windows' `echo` command is a built-in shell command and not an external
// executable like on *nix
const opts = { shell: common.isWindows };

const p = cp.spawn('echo', [], opts);

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

function spawnWithReadable() {
const buffer = [];
const p = cp.spawn('echo', ['123']);
const p = cp.spawn('echo', ['123'], opts);
p.on('close', common.mustCall(function(code, signal) {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
Expand Down

0 comments on commit d54c7c1

Please sign in to comment.