Skip to content

Commit 63ef099

Browse files
cjihrigevanlucas
authored andcommitted
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 9372aee commit 63ef099

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

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

0 commit comments

Comments
(0)