Skip to content

Commit e55e08c

Browse files
jvelezpoMylesBorins
authored andcommitted
test: verify the shell option works properly on execFile
Useful for executing in a shell because it accepts arguments as an array instead of a string as exec does. Depending on the circumstances, that can prove to be useful if the arguments are already prepared. PR-URL: #18384 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 0cf9d04 commit e55e08c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/parallel/test-child-process-execfile.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const uv = process.binding('uv');
66
const fixtures = require('../common/fixtures');
77

88
const fixture = fixtures.path('exit.js');
9+
const execOpts = { encoding: 'utf8', shell: true };
910

1011
{
1112
execFile(
@@ -38,3 +39,10 @@ const fixture = fixtures.path('exit.js');
3839
child.kill();
3940
child.emit('close', code, null);
4041
}
42+
43+
{
44+
// Verify the shell option works properly
45+
execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => {
46+
assert.ifError(err);
47+
}));
48+
}

test/sequential/test-child-process-execsync.js

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const TIMER = 200;
2929
const SLEEP = 2000;
3030

3131
const start = Date.now();
32+
const execOpts = { encoding: 'utf8', shell: true };
3233
let err;
3334
let caught = false;
3435

@@ -124,3 +125,8 @@ assert.strictEqual(ret, `${msg}\n`);
124125
return true;
125126
});
126127
}
128+
129+
// Verify the shell option works properly
130+
assert.doesNotThrow(() => {
131+
execFileSync(process.execPath, [], execOpts);
132+
});

0 commit comments

Comments
 (0)