-
Notifications
You must be signed in to change notification settings - Fork 7
Add code coverage for CMake builds with Clang or GCC #138
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
base: main
Are you sure you want to change the base?
Conversation
Specifically, correct a broken relative link that was created relative to init_repo.sh's directory, not the directory where the link is being placed.
| # libstdc++-10-dev was added for the sake of clang. see: https://stackoverflow.com/q/26333823/10278 | ||
| sudo apt-get --assume-yes install \ | ||
| build-essential \ | ||
| clang \ |
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.
I've assumed (without verifying) that using clang, gcovr, and llvm isn't a concern licensing-wise since they're used as tools, not ingredients. Please let me know if there is any particular due diligence I should do to add these dependencies.
| --overwrite python@3.12 \ | ||
| clang-format@21 \ | ||
| fontconfig \ | ||
| gcovr \ |
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.
I've added coverage dependencies to provision_mac.sh, and I don't think I've done anything more platform-dependent than existing code in CMakeLists.txt and run_all_tests.sh, but coverage on Mac is untested since the only Mac build in CI uses qmake. Feel free to let me know any thoughts on if I should replace or extend .github/workflows/mac2023.yml with a CMake build to run Mac coverage in CI.
| if (PROJECT_IS_TOP_LEVEL) | ||
| set(MYAPP_CLANG_COVERAGE_FLAGS | ||
| " -fprofile-instr-generate \ | ||
| -fcoverage-mapping \ |
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.
In case it's of interest, I'll mention I also tried enabling MC/DC coverage for Clang (adding compile flag -fcoverage-mcdc and giving -show-mcdc to llvm-cov), but oddly that caused the Android build to fail with clang++: error: unknown argument: '-fcoverage-mcdc'. I've noticed the Android build at one point uses a different version of Clang, and with different flags than the main Linux build. I'm afraid I may not immediately be able to prioritize troubleshooting this specific issue further, but where I left it was wondering how MYAPP_CLANG_COVERAGE_FLAGS are even in effect in the Android build, given it doesn't use MYAPP_TEMPLATE_COMPILERCHOICE_CLANG: 1.
|
While testing this locally, I noticed an intriguing line of output from For now, I do not consider this a blocker for merging this PR. (I am still reviewing the PR actively at this moment, so while nothing is blocked, nothing is yet ready-to-merge either.) Anyone interested should probably follow these 2 llvm tickets: |
This PR:
run_all_tests.shto automatically generate.htmlcode coverage reports from runs with code coverage instrumentation present.README.mdandindex.mdto mention these code coverage capabilities.You can see examples of the generated reports from the checks ran for this PR.
This PR also includes unrelated changes to:
cbuild/cbuild_*to.gitignore.init_repo.shthat appears to be broken.