summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2023-03-05 12:49:25 -0500
committerDanielle Adams <adamzdanielle@gmail.com>2023-04-10 22:18:21 -0400
commitd60eef25a1e03c9d12622303012e71490f4491ef (patch)
tree03bcfefb722b7cbee3c922cf9d73849dac8b088d
parentab5b3185f1fa161e063e1e000cec1784808248b6 (diff)
downloadnode-new-d60eef25a1e03c9d12622303012e71490f4491ef.tar.gz
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: https://github.com/nodejs/node/pull/46962 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
-rw-r--r--lib/internal/test_runner/harness.js5
-rw-r--r--lib/internal/test_runner/utils.js17
2 files changed, 7 insertions, 15 deletions
diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js
index a00320a6b0..0b1d7dd85f 100644
--- a/lib/internal/test_runner/harness.js
+++ b/lib/internal/test_runner/harness.js
@@ -16,7 +16,6 @@ const {
const { kEmptyObject } = require('internal/util');
const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test');
const {
- kAsyncBootstrapFailure,
parseCommandLine,
setupTestReporters,
} = require('internal/test_runner/utils');
@@ -30,11 +29,11 @@ function createTestTree(options = kEmptyObject) {
function createProcessEventHandler(eventName, rootTest) {
return (err) => {
- if (err?.failureType === kAsyncBootstrapFailure) {
+ if (!rootTest.harness.bootstrapComplete) {
// Something went wrong during the asynchronous portion of bootstrapping
// the test runner. Since the test runner is not setup properly, we can't
// do anything but throw the error.
- throw err.cause;
+ throw err;
}
// Check if this error is coming from a test. If it is, fail the test.
diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js
index d4564b063f..04427801d4 100644
--- a/lib/internal/test_runner/utils.js
+++ b/lib/internal/test_runner/utils.js
@@ -8,7 +8,6 @@ const {
RegExp,
RegExpPrototypeExec,
SafeMap,
- Symbol,
} = primordials;
const { basename } = require('path');
const { createWriteStream } = require('fs');
@@ -25,7 +24,6 @@ const {
} = require('internal/errors');
const { compose } = require('stream');
-const kAsyncBootstrapFailure = Symbol('asyncBootstrapFailure');
const kMultipleCallbackInvocations = 'multipleCallbackInvocations';
const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;
const kSupportedFileExtensions = /\.[cm]?js$/;
@@ -152,15 +150,11 @@ async function getReportersMap(reporters, destinations) {
async function setupTestReporters(rootTest) {
- try {
- const { reporters, destinations } = parseCommandLine();
- const reportersMap = await getReportersMap(reporters, destinations);
- for (let i = 0; i < reportersMap.length; i++) {
- const { reporter, destination } = reportersMap[i];
- compose(rootTest.reporter, reporter).pipe(destination);
- }
- } catch (err) {
- throw new ERR_TEST_FAILURE(err, kAsyncBootstrapFailure);
+ const { reporters, destinations } = parseCommandLine();
+ const reportersMap = await getReportersMap(reporters, destinations);
+ for (let i = 0; i < reportersMap.length; i++) {
+ const { reporter, destination } = reportersMap[i];
+ compose(rootTest.reporter, reporter).pipe(destination);
}
}
@@ -226,7 +220,6 @@ module.exports = {
doesPathMatchFilter,
isSupportedFileType,
isTestFailureError,
- kAsyncBootstrapFailure,
parseCommandLine,
setupTestReporters,
};