mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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>
This commit is contained in:
2 files changed
+7
-15
No files matched your search
@@ -19,7 +19,6 @@ const { exitCodes: { kGenericUserError } } = internalBinding('errors');
|
||||
const { kEmptyObject } = require('internal/util');
|
||||
const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test');
|
||||
const {
|
||||
kAsyncBootstrapFailure,
|
||||
parseCommandLine,
|
||||
setupTestReporters,
|
||||
} = require('internal/test_runner/utils');
|
||||
@@ -34,11 +33,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.
|
||||
|
||||
@@ -7,7 +7,6 @@ const {
|
||||
RegExp,
|
||||
RegExpPrototypeExec,
|
||||
SafeMap,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
const { basename } = require('path');
|
||||
const { createWriteStream } = require('fs');
|
||||
@@ -24,7 +23,6 @@ const {
|
||||
} = require('internal/errors');
|
||||
const { compose } = require('stream');
|
||||
|
||||
const kAsyncBootstrapFailure = Symbol('asyncBootstrapFailure');
|
||||
const kMultipleCallbackInvocations = 'multipleCallbackInvocations';
|
||||
const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;
|
||||
const kSupportedFileExtensions = /\.[cm]?js$/;
|
||||
@@ -151,15 +149,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +219,6 @@ module.exports = {
|
||||
doesPathMatchFilter,
|
||||
isSupportedFileType,
|
||||
isTestFailureError,
|
||||
kAsyncBootstrapFailure,
|
||||
parseCommandLine,
|
||||
setupTestReporters,
|
||||
};
|
||||
Reference in new issue
Block a user