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 a4b092c

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
test: complete coverage of lib/child_process.js
This commit adds a test which brings coverage of lib/child_process.js to 100%. It adds coverage for the call to uv.errname() in execFile()'s exithandler() function. PR-URL: #12367 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 4786ad7 commit a4b092c
Copy full SHA for a4b092c

File tree

Expand file treeCollapse file tree

1 file changed

+20
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-1
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-execfile.js
+20-1Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
32
const common = require('../common');
43
const assert = require('assert');
54
const execFile = require('child_process').execFile;
65
const path = require('path');
6+
const uv = process.binding('uv');
77

88
const fixture = path.join(common.fixturesDir, 'exit.js');
99

@@ -19,3 +19,22 @@ const fixture = path.join(common.fixturesDir, 'exit.js');
1919
})
2020
);
2121
}
22+
23+
{
24+
// Verify that negative exit codes can be translated to UV error names.
25+
const errorString = `Error: Command failed: ${process.execPath}`;
26+
const code = -1;
27+
const callback = common.mustCall((err, stdout, stderr) => {
28+
assert.strictEqual(err.toString().trim(), errorString);
29+
assert.strictEqual(err.code, uv.errname(code));
30+
assert.strictEqual(err.killed, true);
31+
assert.strictEqual(err.signal, null);
32+
assert.strictEqual(err.cmd, process.execPath);
33+
assert.strictEqual(stdout.trim(), '');
34+
assert.strictEqual(stderr.trim(), '');
35+
});
36+
const child = execFile(process.execPath, callback);
37+
38+
child.kill();
39+
child.emit('close', code, null);
40+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.