test_runner: wait for stderr and stdout to complete

PR-URL: https://github.com/nodejs/node/pull/43666
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Moshe Atlow authored and Michaël Zasso committed 2022-07-31 14:38:50 +02:00
1 parent 61a2ddc597
commit dccbd9ee95
1 file changed
+5 -1
+5 -1
View File
@@ -7,6 +7,8 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeSort,
Promise,
PromiseAll,
SafeArrayIterator,
SafeSet,
} = primordials;
const {
@@ -14,6 +16,7 @@ const {
} = require('internal/bootstrap/pre_execution');
const { spawn } = require('child_process');
const { readdirSync, statSync } = require('fs');
const { finished } = require('internal/streams/end-of-stream');
const console = require('internal/console/global');
const {
codes: {
@@ -126,9 +129,10 @@ function runTestFile(path) {
stderr += chunk;
});
child.once('exit', (code, signal) => {
child.once('exit', async (code, signal) => {
if (code !== 0 || signal !== null) {
if (!err) {
await PromiseAll(new SafeArrayIterator([finished(child.stderr), finished(child.stdout)]));
err = new ERR_TEST_FAILURE('test failed', kSubtestsFailed);
err.exitCode = code;
err.signal = signal;