Skip to content

[Code Coverage] Add a tool to check test coverage of a patch #71841

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

Closed
wants to merge 1 commit into from

Conversation

xgupta
Copy link
Contributor

@xgupta xgupta commented Nov 9, 2023

This Python script creates a patch from the HEAD commit, extracts modified or added source files, test case files, and source code lines, adds coverage instrumentation for the affected source files, runs Lit tests, and records which test cases cause each counter to be executed. Then report the number of test cases executing the counter and the number of test cases executing the counter that are also changed in some way by the patch. Thus providing the developer the information of inadequately tested source lines.

@xgupta
Copy link
Contributor Author

xgupta commented Nov 9, 2023

Moved the code review from Phabricator (https://reviews.llvm.org/D158864) since quite a long we had deprecated Phabricator.

@xgupta xgupta marked this pull request as draft November 16, 2023 17:05
@xgupta xgupta force-pushed the git-check-coverage branch 3 times, most recently from ddfe0aa to 724183f Compare November 20, 2023 14:40
@xgupta xgupta marked this pull request as ready for review November 20, 2023 14:40
@xgupta xgupta force-pushed the git-check-coverage branch from 724183f to d454aa5 Compare November 22, 2023 17:52
@xgupta

This comment was marked as outdated.

@xgupta

This comment was marked as outdated.

@xgupta xgupta force-pushed the git-check-coverage branch 2 times, most recently from 06e5472 to acadd0e Compare November 24, 2023 06:03
@xgupta

This comment was marked as outdated.

@xgupta xgupta force-pushed the git-check-coverage branch 2 times, most recently from 6ba6bfa to e3d3e4d Compare November 26, 2023 15:06
@xgupta

This comment was marked as outdated.

@xgupta xgupta force-pushed the git-check-coverage branch from 91ca211 to 9a86a6e Compare November 27, 2023 07:46
@xgupta

This comment was marked as outdated.

Copy link
Collaborator

@tstellar tstellar left a comment

Choose a reason for hiding this comment

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

I don't know much about coverage, but I don't see any reason not to add this.

@xgupta
Copy link
Contributor Author

xgupta commented Dec 13, 2023

Actually, added a few reviewers who are contributing to LLVM Python code, just to make sure it is following the correct coding practices.

@tru
Copy link
Collaborator

tru commented Dec 13, 2023

I know we are not doing this right now, but I wonder if we should have tests for python scripts as well so that we can run it with our supported python version and see if it works, because it can be hard to spot in a review.

I will make a sweep on the code later today.

@boomanaiden154
Copy link
Contributor

I know we are not doing this right now, but I wonder if we should have tests for python scripts as well so that we can run it with our supported python version and see if it works, because it can be hard to spot in a review.

I am very much in favor of starting to add tests for these utilities. I wouldn't block this patch on having tests, but it's definitely a good practice in general. It's on my todo list to get tests up and running for git-clang-format.

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Quite a few nits, lots of other comments on my initial pass.

This looks like it could be pretty useful. Thanks for putting this together! I'm envisioning this as an on demand job that can be run on a PR with a rich representation reported in a comment (something to be added later) could be a pretty good litmus check for a lot of things.

One question: It seems like this doesn't currently cover cases where only source files or only test files are touched. Just looking at test files might be difficult as there's no way to know what to report. But, looking at just source files I think would be doable (would just require running the whole test suite, not sure how expensive this is) and would be really useful for refactorings and probably other cases.

@xgupta
Copy link
Contributor Author

xgupta commented Aug 17, 2024

Hi @boomanaiden154,

Can you please review it once again. I think this is working fine for most basic usages I tried. We can commit an early version and try to improve it incrementally.

@xgupta xgupta force-pushed the git-check-coverage branch from 8a96e92 to c7978af Compare November 4, 2024 09:49
@xgupta
Copy link
Contributor Author

xgupta commented Nov 4, 2024

Hi

Gentle ping!

@xgupta xgupta force-pushed the git-check-coverage branch 2 times, most recently from 6d20d40 to e5ea8e5 Compare November 7, 2024 08:07
This script create a patch from the HEAD commit, extract modified or added source files, test case files
and source code lines, add coverage instrumentation for the affected source files, runs Lit tests,
and records which test cases cause each counter to be executed. Then report the number of test
cases executing the counter and the number of test cases executing the counter that are also changed
in some way by the patch. Thus providing developer the information of inadequately tested source lines.
@xgupta xgupta force-pushed the git-check-coverage branch from e5ea8e5 to db85592 Compare November 7, 2024 08:08
@xgupta xgupta closed this Feb 10, 2025
@xgupta xgupta deleted the git-check-coverage branch February 10, 2025 10:11
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.

4 participants