Skip to content

Commit 3eb6f61

Browse files
gireeshpunathiltargos
authored andcommitted
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: #25988 PR-URL: #26007 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3cd134c commit 3eb6f61

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/parallel/test-child-process-pipe-dataflow.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@ const MB = KB * KB;
3333
grep = spawn('grep', ['x'], { stdio: [cat.stdout, 'pipe', 'pipe'] });
3434
wc = spawn('wc', ['-c'], { stdio: [grep.stdout, 'pipe', 'pipe'] });
3535

36+
[cat, grep, wc].forEach((child, index) => {
37+
child.stderr.on('data', (d) => {
38+
// Don't want to assert here, as we might miss error code info.
39+
console.error(`got unexpected data from child #${index}:\n${d}`);
40+
});
41+
child.on('exit', common.mustCall(function(code) {
42+
assert.strictEqual(code, 0);
43+
}));
44+
});
45+
3646
wc.stdout.on('data', common.mustCall(function(data) {
3747
assert.strictEqual(data.toString().trim(), MB.toString());
3848
}));
39-
40-
cat.on('exit', common.mustCall(function(code) {
41-
assert.strictEqual(code, 0);
42-
}));
43-
44-
grep.on('exit', common.mustCall(function(code) {
45-
assert.strictEqual(code, 0);
46-
}));
47-
48-
wc.on('exit', common.mustCall(function(code) {
49-
assert.strictEqual(code, 0);
50-
}));
5149
}

0 commit comments

Comments
 (0)