Skip to content

Commit e51d8c6

Browse files
MoLowtargos
authored andcommitted
test_runner: wait for stderr and stdout to complete
PR-URL: #43666 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 1f4f811 commit e51d8c6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/internal/main/test_runner.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ const {
77
ArrayPrototypeSlice,
88
ArrayPrototypeSort,
99
Promise,
10+
PromiseAll,
11+
SafeArrayIterator,
1012
SafeSet,
1113
} = primordials;
1214
const {
1315
prepareMainThreadExecution,
1416
} = require('internal/bootstrap/pre_execution');
1517
const { spawn } = require('child_process');
1618
const { readdirSync, statSync } = require('fs');
19+
const { finished } = require('internal/streams/end-of-stream');
1720
const console = require('internal/console/global');
1821
const {
1922
codes: {
@@ -126,9 +129,10 @@ function runTestFile(path) {
126129
stderr += chunk;
127130
});
128131

129-
child.once('exit', (code, signal) => {
132+
child.once('exit', async (code, signal) => {
130133
if (code !== 0 || signal !== null) {
131134
if (!err) {
135+
await PromiseAll(new SafeArrayIterator([finished(child.stderr), finished(child.stdout)]));
132136
err = new ERR_TEST_FAILURE('test failed', kSubtestsFailed);
133137
err.exitCode = code;
134138
err.signal = signal;

0 commit comments

Comments
 (0)