summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-execfile.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2017-04-12 13:52:36 -0400
committercjihrig <cjihrig@gmail.com>2017-04-18 15:15:19 -0400
commitd2a3651872e08b4b7d13b7f090bb7d0f25e0b817 (patch)
treefae30710308a389d9930f32cc44343cf7c31067a /test/parallel/test-child-process-execfile.js
parentb4f59a7460150bd2e5e5858fb93161547d799633 (diff)
downloadnode-new-d2a3651872e08b4b7d13b7f090bb7d0f25e0b817.tar.gz
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/parallel/test-child-process-execfile.js')
-rw-r--r--test/parallel/test-child-process-execfile.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/parallel/test-child-process-execfile.js b/test/parallel/test-child-process-execfile.js
index ab36aa7b15..f87a4eb115 100644
--- a/test/parallel/test-child-process-execfile.js
+++ b/test/parallel/test-child-process-execfile.js
@@ -1,9 +1,9 @@
'use strict';
-
const common = require('../common');
const assert = require('assert');
const execFile = require('child_process').execFile;
const path = require('path');
+const uv = process.binding('uv');
const fixture = path.join(common.fixturesDir, 'exit.js');
@@ -19,3 +19,22 @@ const fixture = path.join(common.fixturesDir, 'exit.js');
})
);
}
+
+{
+ // Verify that negative exit codes can be translated to UV error names.
+ const errorString = `Error: Command failed: ${process.execPath}`;
+ const code = -1;
+ const callback = common.mustCall((err, stdout, stderr) => {
+ assert.strictEqual(err.toString().trim(), errorString);
+ assert.strictEqual(err.code, uv.errname(code));
+ assert.strictEqual(err.killed, true);
+ assert.strictEqual(err.signal, null);
+ assert.strictEqual(err.cmd, process.execPath);
+ assert.strictEqual(stdout.trim(), '');
+ assert.strictEqual(stderr.trim(), '');
+ });
+ const child = execFile(process.execPath, callback);
+
+ child.kill();
+ child.emit('close', code, null);
+}