From b2a2a55271b609fd09262509ec7f407006bff472 Mon Sep 17 00:00:00 2001 From: jvelezpo Date: Thu, 25 Jan 2018 14:47:52 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/18384 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- test/parallel/test-child-process-execfile.js | 8 ++++++++ test/sequential/test-child-process-execsync.js | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/test/parallel/test-child-process-execfile.js b/test/parallel/test-child-process-execfile.js index 62cc7f534dc86b..a64128d6a3ab6b 100644 --- a/test/parallel/test-child-process-execfile.js +++ b/test/parallel/test-child-process-execfile.js @@ -6,6 +6,7 @@ const uv = process.binding('uv'); const fixtures = require('../common/fixtures'); const fixture = fixtures.path('exit.js'); +const execOpts = { encoding: 'utf8', shell: true }; { execFile( @@ -38,3 +39,10 @@ const fixture = fixtures.path('exit.js'); child.kill(); child.emit('close', code, null); } + +{ + // Verify the shell option works properly + execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => { + assert.ifError(err); + })); +} diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index e7c978406c883e..970ed867abed93 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -8,6 +8,7 @@ const TIMER = 200; const SLEEP = 2000; const start = Date.now(); +const execOpts = { encoding: 'utf8', shell: true }; let err; let caught = false; @@ -103,3 +104,8 @@ assert.strictEqual(ret, `${msg}\n`); return true; }); } + +// Verify the shell option works properly +assert.doesNotThrow(() => { + execFileSync(process.execPath, [], execOpts); +});