Skip to content

Commit

Permalink
test: capture stderr from child processes
Browse files Browse the repository at this point in the history
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: #25988
PR-URL: #26007
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
gireeshpunathil authored and targos committed Feb 11, 2019
1 parent 3cd134c commit 3eb6f61
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/parallel/test-child-process-pipe-dataflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
}

0 comments on commit 3eb6f61

Please sign in to comment.