Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: move coverage collection to root.postRun() #47651

Merged
merged 1 commit into from Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/test_runner/harness.js
@@ -1,6 +1,7 @@
'use strict';
const {
ArrayPrototypeForEach,
FunctionPrototypeBind,
PromiseResolve,
SafeMap,
} = primordials;
Expand Down Expand Up @@ -140,7 +141,6 @@ function setup(root) {
createProcessEventHandler('unhandledRejection', root);
const coverage = configureCoverage(root, globalOptions);
const exitHandler = () => {
root.harness.coverage = collectCoverage(root, coverage);
root.postRun(new ERR_TEST_FAILURE(
'Promise resolution is still pending but the event loop has already resolved',
kCancelledByParent));
Expand All @@ -167,7 +167,7 @@ function setup(root) {
root.harness = {
__proto__: null,
bootstrapComplete: false,
coverage: null,
coverage: FunctionPrototypeBind(collectCoverage, null, root, coverage),
counters: {
__proto__: null,
all: 0,
Expand Down
6 changes: 4 additions & 2 deletions lib/internal/test_runner/test.js
Expand Up @@ -644,8 +644,10 @@ class Test extends AsyncResource {
this.reporter.diagnostic(this.nesting, kFilename, `todo ${this.root.harness.counters.todo}`);
this.reporter.diagnostic(this.nesting, kFilename, `duration_ms ${this.#duration()}`);

if (this.harness?.coverage) {
this.reporter.coverage(this.nesting, kFilename, this.harness.coverage);
const coverage = this.harness.coverage();

if (coverage) {
this.reporter.coverage(this.nesting, kFilename, coverage);
}

this.reporter.push(null);
Expand Down