summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-promisified.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-06-20 12:10:06 -0400
committercjihrig <cjihrig@gmail.com>2019-06-22 13:18:03 -0400
commit3aeb810ca6e2230ae53f7196abd013ec56b94aa8 (patch)
tree3329d3716b91beea292e2763592d9f5a216822db /test/parallel/test-child-process-promisified.js
parent05359dd0dbd00d95fceab63cd72017c58e2f0ce6 (diff)
downloadandroid-node-v8-3aeb810ca6e2230ae53f7196abd013ec56b94aa8.tar.gz
android-node-v8-3aeb810ca6e2230ae53f7196abd013ec56b94aa8.tar.bz2
android-node-v8-3aeb810ca6e2230ae53f7196abd013ec56b94aa8.zip
child_process: attach child in promisification
This commit updates the custom exec() and execFile() promisification to attach the ChildProcess instance to the returned Promise. PR-URL: https://github.com/nodejs/node/pull/28325 Fixes: https://github.com/nodejs/node/issues/28244 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-promisified.js')
-rw-r--r--test/parallel/test-child-process-promisified.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/test/parallel/test-child-process-promisified.js b/test/parallel/test-child-process-promisified.js
index 877bf06662..bc62313099 100644
--- a/test/parallel/test-child-process-promisified.js
+++ b/test/parallel/test-child-process-promisified.js
@@ -8,25 +8,37 @@ const exec = promisify(child_process.exec);
const execFile = promisify(child_process.execFile);
{
- exec(`${process.execPath} -p 42`).then(common.mustCall((obj) => {
+ const promise = exec(`${process.execPath} -p 42`);
+
+ assert(promise.child instanceof child_process.ChildProcess);
+ promise.then(common.mustCall((obj) => {
assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
}));
}
{
- execFile(process.execPath, ['-p', '42']).then(common.mustCall((obj) => {
+ const promise = execFile(process.execPath, ['-p', '42']);
+
+ assert(promise.child instanceof child_process.ChildProcess);
+ promise.then(common.mustCall((obj) => {
assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
}));
}
{
- exec('doesntexist').catch(common.mustCall((err) => {
+ const promise = exec('doesntexist');
+
+ assert(promise.child instanceof child_process.ChildProcess);
+ promise.catch(common.mustCall((err) => {
assert(err.message.includes('doesntexist'));
}));
}
{
- execFile('doesntexist', ['-p', '42']).catch(common.mustCall((err) => {
+ const promise = execFile('doesntexist', ['-p', '42']);
+
+ assert(promise.child instanceof child_process.ChildProcess);
+ promise.catch(common.mustCall((err) => {
assert(err.message.includes('doesntexist'));
}));
}