From cb1687241671732e91959c67202efa73139bd1e8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 20 May 2019 21:55:45 -0700 Subject: [PATCH] test: increase debugging information on failure Increase the information displayed when test-child-process-pipe-dataflow.js fails. PR-URL: https://github.com/nodejs/node/pull/27790 Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- test/parallel/test-child-process-pipe-dataflow.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index 88a31f4ff8429b..abaec73f3ea507 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -38,16 +38,19 @@ const MB = KB * KB; grep.stdout._handle.readStart = common.mustNotCall(); [cat, grep, wc].forEach((child, index) => { - child.stderr.on('data', (d) => { + const errorHandler = (thing, type) => { // 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); + console.error(`unexpected ${type} from child #${index}:\n${thing}`); + }; + + 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}`); })); }); - wc.stdout.on('data', common.mustCall(function(data) { + wc.stdout.on('data', common.mustCall((data) => { assert.strictEqual(data.toString().trim(), MB.toString()); })); }