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

Add option to include or exclude files in the testing coverage #15840

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

abenjaminov
Copy link

This PR adds support for filtering files included or excluded from coverage during bun test. The feature allows users to specify coverageInclude and coverageExclude options in their configuration. Both glob patterns and regular expressions are supported.

For example:

[test]
coverageInclude = ["**/*.service.ts"]
coverageExclude = ["**/*.test.ts"]

How did you verify your code works?

  • I wrote automated tests for the new functionality in patterns.zig and verified they pass.
  • I ran local tests for the matchesGlob, isGlobPattern, matchesRegex, and matchesAnyPattern functions to confirm correctness.
  • I validated the integration by ensuring the coverageInclude and coverageExclude settings work as intended with a sample test configuration.

For Zig changes:

  • I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be.
  • I included a test for the new code, ensuring coverage settings are respected.

@abenjaminov abenjaminov marked this pull request as ready for review December 18, 2024 10:50
@abenjaminov abenjaminov changed the title Jaco/coverage include exclude Add option to include or exclude files in the testing coverage Dec 18, 2024
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

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

Thank you for this PR.

  • Instead of linking and including PCRE2, you can use bun.glob to match globs
  • This will need tests, which you can see examples of in the test folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants