mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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: https://github.com/nodejs/node/pull/7049 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
96ed883d2f
commit
65b5cccee9
1 file changed
+6
-2
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user