Skip to content

Commit 7960ccb

Browse files
cjihrigtargos
authored andcommitted
test_runner: throw if harness is not bootstrapped
This commit updates the test harness to re-throw uncaught errors if bootstrapping has not completed. This updates the existing logic which tried to detect a specific error code. PR-URL: #46962 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent b832d77 commit 7960ccb

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

lib/internal/test_runner/harness.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const { exitCodes: { kGenericUserError } } = internalBinding('errors');
1818
const { kEmptyObject } = require('internal/util');
1919
const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test');
2020
const {
21-
kAsyncBootstrapFailure,
2221
parseCommandLine,
2322
setupTestReporters,
2423
} = require('internal/test_runner/utils');
@@ -32,11 +31,11 @@ function createTestTree(options = kEmptyObject) {
3231

3332
function createProcessEventHandler(eventName, rootTest) {
3433
return (err) => {
35-
if (err?.failureType === kAsyncBootstrapFailure) {
34+
if (!rootTest.harness.bootstrapComplete) {
3635
// Something went wrong during the asynchronous portion of bootstrapping
3736
// the test runner. Since the test runner is not setup properly, we can't
3837
// do anything but throw the error.
39-
throw err.cause;
38+
throw err;
4039
}
4140

4241
// Check if this error is coming from a test. If it is, fail the test.

lib/internal/test_runner/utils.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
RegExp,
88
RegExpPrototypeExec,
99
SafeMap,
10-
Symbol,
1110
} = primordials;
1211
const { basename } = require('path');
1312
const { createWriteStream } = require('fs');
@@ -24,7 +23,6 @@ const {
2423
} = require('internal/errors');
2524
const { compose } = require('stream');
2625

27-
const kAsyncBootstrapFailure = Symbol('asyncBootstrapFailure');
2826
const kMultipleCallbackInvocations = 'multipleCallbackInvocations';
2927
const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;
3028
const kSupportedFileExtensions = /\.[cm]?js$/;
@@ -151,15 +149,11 @@ async function getReportersMap(reporters, destinations) {
151149

152150

153151
async function setupTestReporters(rootTest) {
154-
try {
155-
const { reporters, destinations } = parseCommandLine();
156-
const reportersMap = await getReportersMap(reporters, destinations);
157-
for (let i = 0; i < reportersMap.length; i++) {
158-
const { reporter, destination } = reportersMap[i];
159-
compose(rootTest.reporter, reporter).pipe(destination);
160-
}
161-
} catch (err) {
162-
throw new ERR_TEST_FAILURE(err, kAsyncBootstrapFailure);
152+
const { reporters, destinations } = parseCommandLine();
153+
const reportersMap = await getReportersMap(reporters, destinations);
154+
for (let i = 0; i < reportersMap.length; i++) {
155+
const { reporter, destination } = reportersMap[i];
156+
compose(rootTest.reporter, reporter).pipe(destination);
163157
}
164158
}
165159

@@ -225,7 +219,6 @@ module.exports = {
225219
doesPathMatchFilter,
226220
isSupportedFileType,
227221
isTestFailureError,
228-
kAsyncBootstrapFailure,
229222
parseCommandLine,
230223
setupTestReporters,
231224
};

0 commit comments

Comments
 (0)