-
-
Notifications
You must be signed in to change notification settings - Fork 626
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
Jacoco report target filtering. #6736
Jacoco report target filtering. #6736
Conversation
…argets included in reports using a list of regular expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
testprojects/src/java/org/pantsbuild/testproject/coverage/BUILD
Outdated
Show resolved
Hide resolved
testprojects/src/java/org/pantsbuild/testproject/coverage/one/BUILD
Outdated
Show resolved
Hide resolved
testprojects/src/java/org/pantsbuild/testproject/coverage/two/BUILD
Outdated
Show resolved
Hide resolved
testprojects/tests/java/org/pantsbuild/testproject/coverage/BUILD
Outdated
Show resolved
Hide resolved
testprojects/tests/java/org/pantsbuild/testproject/coverage/BUILD
Outdated
Show resolved
Hide resolved
…age targets earlier. Cleans up test project build files.
…Jacoco doesn't complain that it's instantiated with an empty set of test targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good! Will merge on green.
You hit a flaky test. Going to merge. Thanks! |
Can someone give an example of using this new filter option, cannot find it in the documentation for junit test? I am using pants 1.15.0, tried to set the option in this way: The full command:
I checked release history, 1.15.0 is released on 4/15/2019, so this PR should be included already? Can someone give some idea how to use this new filter option? |
I think it's just |
@baroquebobcat yes, |
It should be, under |
@stuhood found it under |
Adds an argument for the jacoco jvm coverage processor that filters targets included in reports using a list of regular expressions.
Problem
The current implementation of jacoco code coverage will produce a report that includes all targets used in the test run. This includes targets not directly under test, but dependencies of the package actually under test. As a result, there's a lot of undesirable noise in the reports.
Solution
Introduce a parameter to filter the class files supplied to the jacoco cli when the report is produced. The jacoco cli does not provide a native parameter for exclusions, and instead the best we can do is to exclude class files when generating the reports. Classes that aren't passed to the cli during report generation aren't included in the resulting report.
The parameter I've added is a list of regular expressions. When specified, pants will only pass targets that match one of the regexes to the cli during report generation. Any target that doesn't match the pattern will be excluded, and thus not show up in the report.