feat: Support excluding source paths from coverage reporting #1809
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Sometimes the coverage reporting will report on source files that really shouldn't be in the coverage report, giving wildly skewed results. See #1749 for an example of somebody reporting this issue or see the following screenshot where I ran into this today while working on a Minecraft modding project (the coverage reporter is reporting on the Minecraft source code in addition to my own).
Solution
Add a new configuration option:
java.test.config.coverage.excludes. This option supports any "globbing" pattern supported by minimatch internally since it's used for the pattern matching support. Run the list of files returned by the coverage provider through this pattern matcher set. Only provide coverage results from the total set that aren't excluded by the patterns.Empty lists will still return all coverage results, see the below screenshot.
See the below screenshots for examples of working patterns.
Filtering the entire build directory.
Filtering only one path out of several.
Multiple path filters.