Skip to content

Commit 8e3d54a

Browse files
cjihrigevanlucas
authored andcommittedMay 2, 2017
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 <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 922c457 commit 8e3d54a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

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

+20-1
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)
Please sign in to comment.