Skip to content

Commit 8040d8b

Browse files
Trotttargos
authored andcommitted
test: increase debugging information on failure
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]>
1 parent 588fd0c commit 8040d8b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ const MB = KB * KB;
3838
grep.stdout._handle.readStart=common.mustNotCall();
3939

4040
[cat,grep,wc].forEach((child,index)=>{
41-
child.stderr.on('data',(d)=>{
41+
consterrorHandler=(thing,type)=>{
4242
// Don't want to assert here, as we might miss error code info.
43-
console.error(`got unexpected data from child #${index}:\n${d}`);
44-
});
45-
child.on('exit',common.mustCall(function(code){
46-
assert.strictEqual(code,0);
43+
console.error(`unexpected ${type} from child #${index}:\n${thing}`);
44+
};
45+
46+
child.stderr.on('data',(d)=>{errorHandler(d,'data');});
47+
child.on('error',(err)=>{errorHandler(err,'error');});
48+
child.on('exit',common.mustCall((code)=>{
49+
assert.strictEqual(code,0,`child ${index} exited with code ${code}`);
4750
}));
4851
});
4952

50-
wc.stdout.on('data',common.mustCall(function(data){
53+
wc.stdout.on('data',common.mustCall((data)=>{
5154
assert.strictEqual(data.toString().trim(),MB.toString());
5255
}));
5356
}

0 commit comments

Comments
(0)