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

Coverage report for CMake #1754

Open
david-drinn opened this issue May 22, 2023 · 1 comment
Open

Coverage report for CMake #1754

david-drinn opened this issue May 22, 2023 · 1 comment

Comments

@david-drinn
Copy link

The coverage report seemed to have been implemented with #1139 and #1394, but at some point I guess support was removed. There's no longer any mention of --coverage in the CMake files, and if I provide the -DCOVERAGE=ON as in the scripts/travis_ci_build.sh file, CMake warns that it's not used. I can't find any relevant make targets for coverage as mentioned in the docs.

@offa mentions in #1394 (comment) that gcovr is easy to use, so I'm trying to work it out now. But it would be nice if it was added back to the CMake builds.

@thetic
Copy link
Contributor

thetic commented May 23, 2023

The COVERAGE option was intended to enable coverage for CppUTest's own tests.
Enable coverage by setting the appropriate compile options in your own project.
For example, for GCC:

add_compile_options(--coverage)

(See https://cmake.org/cmake/help/latest/command/add_compile_options.html.)

You can also add flags ad hoc from the command line when configuring your project:

cmake -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage # ...

(See https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html.)

gcovr is great for generating reports once you've run your instrumented tests.
You should be able to simply run gcovr --txt or gcovr --html from the working directory.

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

No branches or pull requests

2 participants