summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-promisified.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-04-16 21:29:26 +0200
committerAnna Henningsen <anna@addaleax.net>2017-05-09 15:01:45 +0200
commitfe5ca3ff27d3d94386edab0f9328df534da599aa (patch)
tree69200b89d8f0161ae29e7cd86a9137b288a16dd9 /test/parallel/test-child-process-promisified.js
parentfbcb4f50b81cc57774998b2c3172626b6e4288be (diff)
downloadandroid-node-v8-fe5ca3ff27d3d94386edab0f9328df534da599aa.tar.gz
android-node-v8-fe5ca3ff27d3d94386edab0f9328df534da599aa.tar.bz2
android-node-v8-fe5ca3ff27d3d94386edab0f9328df534da599aa.zip
child_process: support promisified `exec(File)`
Author: Benjamin Gruenbaum <inglor@gmail.com> Author: Anna Henningsen <anna@addaleax.net> PR-URL: https://github.com/nodejs/node/pull/12442 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: William Kapke <william.kapke@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-promisified.js')
-rw-r--r--test/parallel/test-child-process-promisified.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/parallel/test-child-process-promisified.js b/test/parallel/test-child-process-promisified.js
new file mode 100644
index 0000000000..322cb110eb
--- /dev/null
+++ b/test/parallel/test-child-process-promisified.js
@@ -0,0 +1,34 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const child_process = require('child_process');
+const { promisify } = require('util');
+
+common.crashOnUnhandledRejection();
+
+const exec = promisify(child_process.exec);
+const execFile = promisify(child_process.execFile);
+
+{
+ exec(`${process.execPath} -p 42`).then(common.mustCall((obj) => {
+ assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
+ }));
+}
+
+{
+ execFile(process.execPath, ['-p', '42']).then(common.mustCall((obj) => {
+ assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
+ }));
+}
+
+{
+ exec('doesntexist').catch(common.mustCall((err) => {
+ assert(err.message.includes('doesntexist'));
+ }));
+}
+
+{
+ execFile('doesntexist', ['-p', '42']).catch(common.mustCall((err) => {
+ assert(err.message.includes('doesntexist'));
+ }));
+}