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 committed Mar 7, 2023
1 parent b191f09 commit 4e3bc06
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 @@ -182,13 +182,14 @@ function getGlobalRoot() {
globalRoot.reporter.once('test:fail', () => {
process.exitCode = kGenericUserError;
});
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 @@ -387,13 +387,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 @@ -150,13 +150,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 4e3bc06

Please sign in to comment.