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

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎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
functioncreateProcessEventHandler(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-
throwerr.cause;
36+
throwerr;
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-
constkAsyncBootstrapFailure=Symbol('asyncBootstrapFailure');
2927
constkMultipleCallbackInvocations='multipleCallbackInvocations';
3028
constkRegExpPattern=/^\/(.*)\/([a-z]*)$/;
3129
constkSupportedFileExtensions=/\.[cm]?js$/;
@@ -152,15 +150,11 @@ async function getReportersMap(reporters, destinations) {
152150

153151

154152
asyncfunctionsetupTestReporters(rootTest){
155-
try{
156-
const{ reporters, destinations }=parseCommandLine();
157-
constreportersMap=awaitgetReportersMap(reporters,destinations);
158-
for(leti=0;i<reportersMap.length;i++){
159-
const{ reporter, destination }=reportersMap[i];
160-
compose(rootTest.reporter,reporter).pipe(destination);
161-
}
162-
}catch(err){
163-
thrownewERR_TEST_FAILURE(err,kAsyncBootstrapFailure);
153+
const{ reporters, destinations }=parseCommandLine();
154+
constreportersMap=awaitgetReportersMap(reporters,destinations);
155+
for(leti=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)