Skip to content

Improve specificity of ignored files in coverage reports #961

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

Merged

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Jul 9, 2024

Code coverage reports are filtered to omit the tests themselves, as well as all library code checked out in .build. This is done with the --ignore-filename-regex argument passed to llvm-cov's export command.

The current filter is defined as
Tests|swift-testing|Testing|.build|Snippets|Plugins, and filters out files if they contain any of those strings in their filename. This can be too aggressive, and was filtering out valid files under test and omitting them from reports. For instance the file SwiftTestingScanner.swift is filtered out of the coverage report for the sourcekit-lsp repository despite being a valid file to be covered.

Instead, filter with fully qualified paths for each test target's source directory and the .build folder. This omits Tests and library code while avoiding the problem outlined above.

Code coverage reports are filtered to omit the tests themselves, as well
as all library code checked out in `.build`. This is done with the
`--ignore-filename-regex` argument passed to llvm-cov's `export` command.

The current filter is defined as
`Tests|swift-testing|Testing|.build|Snippets|Plugins`, and filters out
all files if they contain any of those strings in their filename. This
can be too aggressive, and was filtering out valid files under test and
omitting them from reports. For instance the file
`SwiftTestingScanner.swift` is filtered out of the coverage report for
the sourcekit-lsp repository despite being a valid file to be covered.

Instead, filter with fully qualified paths for each test target's source
directory and the `.build` folder. This omits Tests and library code
while avoiding the problem outlined above.
@matthewbastien matthewbastien merged commit c002d57 into swiftlang:main Jul 10, 2024
8 checks passed
@plemarquand plemarquand deleted the better-coverage-filename-regex branch July 10, 2024 17:54
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.

2 participants