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: remove root tracking set #46961

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const {
ArrayPrototypeForEach,
PromiseResolve,
SafeMap,
SafeWeakSet,
} = primordials;
const {
createHook,
Expand All @@ -25,7 +24,6 @@ const {
const { bigint: hrtime } = process.hrtime;

const testResources = new SafeMap();
const wasRootSetup = new SafeWeakSet();

function createTestTree(options = kEmptyObject) {
return setup(new Test({ __proto__: null, ...options, name: '<root>' }));
Expand Down Expand Up @@ -108,7 +106,7 @@ function collectCoverage(rootTest, coverage) {
}

function setup(root) {
if (wasRootSetup.has(root)) {
if (root.startTime !== null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this change mean that someone could create a Test themselves, and be able to monkey with the harness? By using a weakest you’re ensuring that only things you create are treated as such.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think userland has access to any of the necessary APIs (the Test class or any of the harness internals) to do that.

return root;
}

Expand Down Expand Up @@ -172,8 +170,6 @@ function setup(root) {
coverage: null,
};
root.startTime = hrtime();

wasRootSetup.add(root);
return root;
}

Expand Down