summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-promisified.js
diff options
context:
space:
mode:
authorGil Tayar <gil@tayar.org>2017-06-02 11:46:46 +0300
committerAnna Henningsen <anna@addaleax.net>2017-06-09 21:46:09 +0200
commit8d7f07f3799d5b4ec541eb606e785d7ce17e82d0 (patch)
tree8880c0242ced4d148180ee5a0f8e1d24572ff90d /test/parallel/test-child-process-promisified.js
parent55f9c85a0511adbb110e1521015244d8686c548b (diff)
downloadandroid-node-v8-8d7f07f3799d5b4ec541eb606e785d7ce17e82d0.tar.gz
android-node-v8-8d7f07f3799d5b4ec541eb606e785d7ce17e82d0.tar.bz2
android-node-v8-8d7f07f3799d5b4ec541eb606e785d7ce17e82d0.zip
child_process: promisify includes stdio in error
This converts the initial implementation of a promised exec that used the customPromisifyArgs support in util.promisify with a custom implementation. This is because exec and execFile, when there is an error, still supply the stdout and stderr of the process, and yet the promisified version with customPromisifyArgs does not supply this ability. I created a custom implementation and attached it to exec and execFile using the util.promisify.custom key. Fixes: https://github.com/nodejs/node/issues/13364 PR-URL: https://github.com/nodejs/node/pull/13388 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-child-process-promisified.js')
-rw-r--r--test/parallel/test-child-process-promisified.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-child-process-promisified.js b/test/parallel/test-child-process-promisified.js
index 322cb110eb..0fa9c68a92 100644
--- a/test/parallel/test-child-process-promisified.js
+++ b/test/parallel/test-child-process-promisified.js
@@ -32,3 +32,22 @@ const execFile = promisify(child_process.execFile);
assert(err.message.includes('doesntexist'));
}));
}
+const failingCodeWithStdoutErr =
+ 'console.log(42);console.error(43);process.exit(1)';
+{
+ exec(`${process.execPath} -e "${failingCodeWithStdoutErr}"`)
+ .catch(common.mustCall((err) => {
+ assert.strictEqual(err.code, 1);
+ assert.strictEqual(err.stdout, '42\n');
+ assert.strictEqual(err.stderr, '43\n');
+ }));
+}
+
+{
+ execFile(process.execPath, ['-e', failingCodeWithStdoutErr])
+ .catch(common.mustCall((err) => {
+ assert.strictEqual(err.code, 1);
+ assert.strictEqual(err.stdout, '42\n');
+ assert.strictEqual(err.stderr, '43\n');
+ }));
+}