(testPlatform, shell, shellOutput)
| 59 | Object.defineProperty(process, 'platform', { get: () => platform }); |
| 60 | |
| 61 | function test(testPlatform, shell, shellOutput) { |
| 62 | platform = testPlatform; |
| 63 | const isCmd = /^(?:.*\\)?cmd(?:\.exe)?$/i.test(shellOutput); |
| 64 | const cmd = 'not_a_real_command'; |
| 65 | |
| 66 | const shellFlags = isCmd ? ['/d', '/s', '/c'] : ['-c']; |
| 67 | const outputCmd = isCmd ? `"${cmd}"` : cmd; |
| 68 | const windowsVerbatim = isCmd ? true : undefined; |
| 69 | internalCp.spawnSync = common.mustCall(function(opts) { |
| 70 | assert.strictEqual(opts.file, shellOutput); |
| 71 | assert.deepStrictEqual(opts.args, |
| 72 | [shellOutput, ...shellFlags, outputCmd]); |
| 73 | assert.strictEqual(opts.shell, shell); |
| 74 | assert.strictEqual(opts.file, opts.file); |
| 75 | assert.deepStrictEqual(opts.args, opts.args); |
| 76 | assert.strictEqual(opts.windowsHide, false); |
| 77 | assert.strictEqual(opts.windowsVerbatimArguments, |
| 78 | !!windowsVerbatim); |
| 79 | }); |
| 80 | cp.spawnSync(cmd, { shell }); |
| 81 | internalCp.spawnSync = oldSpawnSync; |
| 82 | } |
| 83 | |
| 84 | // Test Unix platforms with the default shell. |
| 85 | test('darwin', true, '/bin/sh'); |
no test coverage detected
searching dependent graphs…