Skip to content

Commit

Permalink
test: increase debugging information on failure
Browse files Browse the repository at this point in the history
Increase the information displayed when
test-child-process-pipe-dataflow.js fails.

PR-URL: #27790
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
Trott authored and targos committed May 28, 2019
1 parent 588fd0c commit 8040d8b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}));
}

0 comments on commit 8040d8b

Please sign in to comment.