diff options
author | Rich Trott <rtrott@gmail.com> | 2019-12-02 05:21:37 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-12-04 05:36:49 -0800 |
commit | b29986040ef38b0d798fa28cf0df228e0dbdabe6 (patch) | |
tree | 9dd788318385d6fff8642f18b342507b016dac2d /test | |
parent | b9cacfc999c005b5aeefc1d0ba0f0ae1651686b1 (diff) | |
download | android-node-v8-b29986040ef38b0d798fa28cf0df228e0dbdabe6.tar.gz android-node-v8-b29986040ef38b0d798fa28cf0df228e0dbdabe6.tar.bz2 android-node-v8-b29986040ef38b0d798fa28cf0df228e0dbdabe6.zip |
test: increase debugging information in subprocess test
Refs: https://github.com/nodejs/node/issues/25988#issuecomment-560394046
PR-URL: https://github.com/nodejs/node/pull/30761
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-child-process-pipe-dataflow.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index abaec73f3e..bc5e4e02fd 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -37,6 +37,14 @@ const MB = KB * KB; cat.stdout._handle.readStart = common.mustNotCall(); grep.stdout._handle.readStart = common.mustNotCall(); + // Keep an array of error codes and assert on them during process exit. This + // is because stdio can still be open when a child process exits, and we don't + // want to lose information about what caused the error. + const errors = []; + process.on('exit', () => { + assert.deepStrictEqual(errors, []); + }); + [cat, grep, wc].forEach((child, index) => { const errorHandler = (thing, type) => { // Don't want to assert here, as we might miss error code info. @@ -46,7 +54,9 @@ const MB = KB * KB; child.stderr.on('data', (d) => { errorHandler(d, 'data'); }); child.on('error', (err) => { errorHandler(err, 'error'); }); child.on('exit', common.mustCall((code) => { - assert.strictEqual(code, 0, `child ${index} exited with code ${code}`); + if (code !== 0) { + errors.push(`child ${index} exited with code ${code}`); + } })); }); |