diff options
author | Gireesh Punathil <gpunathi@in.ibm.com> | 2019-02-08 07:52:02 -0500 |
---|---|---|
committer | Gireesh Punathil <gpunathi@in.ibm.com> | 2019-02-11 09:33:58 +0530 |
commit | 448b0c0afcd87f93aab8b863dcaf463827814ad5 (patch) | |
tree | 39390b199216275fa6e84a9ce096a925366e7b68 /test | |
parent | 1847696f4b6284bad45f452bc8595927074118dc (diff) | |
download | android-node-v8-448b0c0afcd87f93aab8b863dcaf463827814ad5.tar.gz android-node-v8-448b0c0afcd87f93aab8b863dcaf463827814ad5.tar.bz2 android-node-v8-448b0c0afcd87f93aab8b863dcaf463827814ad5.zip |
test: capture stderr from child processes
If the test fails with errors from the child commands,
there is no debug info. Suppliment the stderr data
so that we know what to look for.
Refs: https://github.com/nodejs/node/issues/25988
PR-URL: https://github.com/nodejs/node/pull/26007
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-child-process-pipe-dataflow.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index 501fb29032..f5068b5d36 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -33,19 +33,17 @@ const MB = KB * KB; grep = spawn('grep', ['x'], { stdio: [cat.stdout, 'pipe', 'pipe'] }); wc = spawn('wc', ['-c'], { stdio: [grep.stdout, 'pipe', 'pipe'] }); + [cat, grep, wc].forEach((child, index) => { + child.stderr.on('data', (d) => { + // Don't want to assert here, as we might miss error code info. + console.error(`got unexpected data from child #${index}:\n${d}`); + }); + child.on('exit', common.mustCall(function(code) { + assert.strictEqual(code, 0); + })); + }); + wc.stdout.on('data', common.mustCall(function(data) { assert.strictEqual(data.toString().trim(), MB.toString()); })); - - cat.on('exit', common.mustCall(function(code) { - assert.strictEqual(code, 0); - })); - - grep.on('exit', common.mustCall(function(code) { - assert.strictEqual(code, 0); - })); - - wc.on('exit', common.mustCall(function(code) { - assert.strictEqual(code, 0); - })); } |