Skip to content

Commit 448b0c0

Browse files
committedFeb 11, 2019
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: nodejs#25988 PR-URL: nodejs#26007 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1847696 commit 448b0c0

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)
Please sign in to comment.