Skip to content

Commit

Permalink
test_runner: track bootstrapping process
Browse files Browse the repository at this point in the history
This commit updates the test harness and root test to track
when bootstrapping has completed.

PR-URL: #46962
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
cjihrig authored and danielleadams committed Apr 11, 2023
1 parent c463f13 commit ab5b318
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ function getGlobalRoot() {
globalRoot.reporter.once('test:fail', () => {
process.exitCode = 1;
});
reportersSetup = setupTestReporters(globalRoot.reporter);
reportersSetup = setupTestReporters(globalRoot);
}
return globalRoot;
}

async function startSubtest(subtest) {
await reportersSetup;
getGlobalRoot().harness.bootstrapComplete = true;
await subtest.start();
}

Expand Down
15 changes: 9 additions & 6 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,16 @@ function run(options) {
filesWatcher = watchFiles(testFiles, root, inspectPort);
postRun = undefined;
}
const runFiles = () => SafePromiseAllSettledReturnVoid(testFiles, (path) => {
const subtest = runTestFile(path, root, inspectPort, filesWatcher);
runningSubtests.set(path, subtest);
return subtest;
});
const runFiles = () => {
root.harness.bootstrapComplete = true;
return SafePromiseAllSettledReturnVoid(testFiles, (path) => {
const subtest = runTestFile(path, root, inspectPort, filesWatcher);
runningSubtests.set(path, subtest);
return subtest;
});
};

PromisePrototypeThen(PromisePrototypeThen(PromiseResolve(setup?.(root.reporter)), runFiles), postRun);
PromisePrototypeThen(PromisePrototypeThen(PromiseResolve(setup?.(root)), runFiles), postRun);

return root.reporter;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ async function getReportersMap(reporters, destinations) {
}


async function setupTestReporters(testsStream) {
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(testsStream, reporter).pipe(destination);
compose(rootTest.reporter, reporter).pipe(destination);
}
} catch (err) {
throw new ERR_TEST_FAILURE(err, kAsyncBootstrapFailure);
Expand Down

0 comments on commit ab5b318

Please sign in to comment.