Skip to content

Commit 527db40

Browse files
cjihrigMyles Borins
authored and
Myles Borins
committed
test: add coverage for execFileSync() errors
This commit adds coverage for errors returned by execFileSync() when the child process exits with a non-zero code. PR-URL: #9211 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 91fce10 commit 527db40

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,19 @@ assert.strictEqual(ret, msg + '\n',
8787
execSync('exit -1', {stdio: 'ignore'});
8888
}, /Command failed: exit -1/);
8989
})();
90+
91+
// Verify the execFileSync() behavior when the child exits with a non-zero code.
92+
{
93+
const args = ['-e', 'process.exit(1)'];
94+
95+
assert.throws(() => {
96+
execFileSync(process.execPath, args);
97+
}, (err) => {
98+
const msg = `Command failed: ${process.execPath} ${args.join(' ')}`;
99+
100+
assert(err instanceof Error);
101+
assert.strictEqual(err.message.trim(), msg);
102+
assert.strictEqual(err.status, 1);
103+
return true;
104+
});
105+
}

0 commit comments

Comments
 (0)