Skip to content

Commit d60eef2

Browse files
cjihrigdanielleadams
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 ab5b318 commit d60eef2

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

lib/internal/test_runner/harness.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const {
1616
const { kEmptyObject } = require('internal/util');
1717
const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test');
1818
const {
19-
kAsyncBootstrapFailure,
2019
parseCommandLine,
2120
setupTestReporters,
2221
} = require('internal/test_runner/utils');
@@ -30,11 +29,11 @@ function createTestTree(options = kEmptyObject) {
3029

3130
function createProcessEventHandler(eventName, rootTest) {
3231
return (err) => {
33-
if (err?.failureType === kAsyncBootstrapFailure) {
32+
if (!rootTest.harness.bootstrapComplete) {
3433
// Something went wrong during the asynchronous portion of bootstrapping
3534
// the test runner. Since the test runner is not setup properly, we can't
3635
// do anything but throw the error.
37-
throw err.cause;
36+
throw err;
3837
}
3938

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

lib/internal/test_runner/utils.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
RegExp,
99
RegExpPrototypeExec,
1010
SafeMap,
11-
Symbol,
1211
} = primordials;
1312
const { basename } = require('path');
1413
const { createWriteStream } = require('fs');
@@ -25,7 +24,6 @@ const {
2524
} = require('internal/errors');
2625
const { compose } = require('stream');
2726

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

153151

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

@@ -226,7 +220,6 @@ module.exports = {
226220
doesPathMatchFilter,
227221
isSupportedFileType,
228222
isTestFailureError,
229-
kAsyncBootstrapFailure,
230223
parseCommandLine,
231224
setupTestReporters,
232225
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy