Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 527db40

Browse filesBrowse files
cjihrigMyles Borins
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 <targos@protonmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 91fce10 commit 527db40
Copy full SHA for 527db40

File tree

Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/sequential/test-child-process-execsync.js
+16Lines 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
}, /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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.