Skip to content

Code Coverage

Russell Blickhan edited this page Jul 4, 2018 · 2 revisions

I (Russell) am putting here notes I've collecting while trying to get code coverage to work.

  • gcov seems to be the de facto standard for C++ code coverage. It's technically a gcc thing but it seems like clang has a compatible mode. Basically as I understand it, you first compile your test executable with certain flags, run the executable, then run the gcov utility and tell it which C++ source files you want analyzed.
  • This blog post is the most helpful thing I could find. But! I still can't get it working.
  • Here's the CMake script I was trying to use. I can't tell if it's even doing anything, though, because it doesn't seem to output anything (but I did see a crash when it couldn't find lcov... also I'm not sure how lcov even fits into this).
  • This clang docs page is about "source-based coverage" (which seems like it would be the way to go except I see no evidence coveralls/codecov.io support it 🤷‍♀️), but it does cryptically mention "gcov - A GCC-compatible coverage implementation which operates on DebugInfo. This is enabled by -ftest-coverage or --coverage." Oh clang, if only you had documentation on it...
  • This mailing list says clang needs to link against a library called libprofile_rt, but also that the --coverage flag, passed during linking, implies it, so this might not be important.
  • This repo seems promising for Coveralls integration.
  • This repo seems promising for Codecov.io integration.
Clone this wiki locally