MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-child-process-spawnsync-shell.js:61–82  ·  view source on GitHub ↗
(testPlatform, shell, shellOutput)

Source from the content-addressed store, hash-verified

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');

Calls 1

testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…