Skip to content

Commit

Permalink
test: fix spawnsync-shell to check correct options on Windows
Browse files Browse the repository at this point in the history
This test expected to use cmd.exe options even if
the shell was powershell. This commit fixes to check correct options
for shells other than cmd.exe.
  • Loading branch information
tkamenoko committed Jul 26, 2018
1 parent 6b779f8 commit 17ded87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/child_process.js
Expand Up @@ -450,7 +450,7 @@ function normalizeSpawnArguments(file, args, options) {

// Validate windowsHide, if present.
if (options.windowsHide != null &&
typeof options.windowsHide !== 'boolean') {
typeof options.windowsHide !== 'boolean') {
throw new ERR_INVALID_ARG_TYPE('options.windowsHide',
'boolean', options.windowsHide);
}
Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-child-process-spawnsync-shell.js
Expand Up @@ -54,11 +54,13 @@ assert.strictEqual(env.stdout.toString().trim(), 'buzz');

function test(testPlatform, shell, shellOutput) {
platform = testPlatform;

const isCmd = shellOutput.endsWith('cmd.exe') ||
shellOutput.endsWith('cmd');
const cmd = 'not_a_real_command';
const shellFlags = platform === 'win32' ? ['/d', '/s', '/c'] : ['-c'];
const outputCmd = platform === 'win32' ? `"${cmd}"` : cmd;
const windowsVerbatim = platform === 'win32' ? true : undefined;

const shellFlags = isCmd ? ['/d', '/s', '/c'] : ['-c'];
const outputCmd = isCmd ? `"${cmd}"` : cmd;
const windowsVerbatim = isCmd ? true : undefined;
internalCp.spawnSync = common.mustCall(function(opts) {
assert.strictEqual(opts.file, shellOutput);
assert.deepStrictEqual(opts.args,
Expand Down

0 comments on commit 17ded87

Please sign in to comment.