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

Java-coverage: Add logic to exclude dependencies in JVM coverage report #10860

Closed
wants to merge 3 commits into from

Conversation

arthurscchan
Copy link
Contributor

@arthurscchan arthurscchan commented Aug 18, 2023

This PR resolves #10826 by using the COVERAGE_EXTRA_ARGS from project.yaml or helper.py script to retrieve a TARGET_PACKAGE_PREFIX list to specify what class packages to be included in the Jacoco HTML report for JVM projects.

Sample result for project Joni before the PR
Screenshot 2023-11-10 at 10 20 49 PM

Sample result after the PR is applied
Screenshot 2023-11-10 at 10 20 19 PM

The additional field added to project.yaml
coverage_extra_args: TARGET_PACKAGE_PREFIX=org.joni.*

@arthurscchan arthurscchan force-pushed the fix-jvm-coverage branch 2 times, most recently from 880cf34 to 22108da Compare August 18, 2023 19:23
infra/base-images/base-runner/coverage Outdated Show resolved Hide resolved
infra/base-images/base-runner/coverage Outdated Show resolved Hide resolved
infra/base-images/base-runner/coverage Show resolved Hide resolved
@arthurscchan arthurscchan force-pushed the fix-jvm-coverage branch 3 times, most recently from 63e07c3 to 9e61819 Compare August 23, 2023 20:34
@arthurscchan arthurscchan marked this pull request as ready for review November 10, 2023 23:15
@DavidKorczynski
Copy link
Collaborator

I'll review this tomorrow!

@arthurscchan
Copy link
Contributor Author

It is found that it maybe better to do this per project by separating the dependencies jar and project code jar to avoid Jacoco generating the reports for those dependencies jar. Currnetly, Jacoco only generate reports on all jar existing in the $OUT directory. Putting dependencies in inner directory like $OUT/dependency will exclude them from Jacoco report which is an alternatives. Thus closing this PR.

centic9 added a commit to centic9/oss-fuzz that referenced this pull request Dec 29, 2023
…included in coverage report

Introduce two jar-files to separate .class files into two jar files, one
which is included in coverage reporting and one which contains libraries
which should not appear in the coverage report.

Unfortunately this only allows control on "artifact" level, which means single
uninteresting classes/packages cannot be excluded.

Related to google#10826 and google#10860

(cherry picked from commit 2b48e656646d4c3aa61ea44b5b3edef59942f142)
DavidKorczynski pushed a commit that referenced this pull request Dec 29, 2023
…eptions (#11418)

As a general solution for handling excluding classes from JaCoCo
coverage counting was not merged (See #10860#issuecomment-1870891873 ),
this PR tries to implement a different approach which separates the
class-files into two jar-files and this way at least allows to exclude
code of third-party libraries when reporting coverage of fuzzing.

Also add two expected exceptions and adjust one limit to match the
amount of memory which oss-fuzz uses here.
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.

How can we exclude some Java packages from the coverage report
2 participants