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

feat(testing/unstable): add API for configuring global sanitizer state #6282

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Dec 19, 2024

This PR adds unstable API configureGlobalSanitizers in @std/testing/unstable-bdd. You can modify sanitizers state globally for bdd style test cases.

A typical usage is:

import { describe, it } from "@std/testing/bdd";
import { configureGlobalSanitizers } from "@std/testing/unstable-bdd";

configureGlobalSanitizers({
  sanitizeOps: false,
  sanitizeResources: false,
});

it("leaks ops", () => {
  setTimeout(() => {}, 1000);
});

describe("leaks ops", () => {
  it("leaks ops", () => {
    setTimeout(() => {}, 1000);
  });
});

This allows the op and resource leaks from setTimeout

configureGlobalSanitizers API needs to be called before the first describe or it call.

@kt3k kt3k requested a review from bartlomieju December 19, 2024 07:15
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.33%. Comparing base (450bdfb) to head (b91267f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...l_sanitizers/disable_sanitize_ops_and_resources.ts 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6282      +/-   ##
==========================================
+ Coverage   96.32%   96.33%   +0.01%     
==========================================
  Files         544      547       +3     
  Lines       41620    41661      +41     
  Branches     6313     6313              
==========================================
+ Hits        40091    40135      +44     
+ Misses       1486     1484       -2     
+ Partials       43       42       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kt3k kt3k merged commit 990015d into denoland:main Dec 20, 2024
18 checks passed
@kt3k kt3k deleted the testing-unstable-configure-global-sanitizers branch December 20, 2024 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants