[CMake] Running coverage analysis

David Cole david.cole at kitware.com
Tue Jan 3 10:47:09 EST 2012


The way I have always approached problems like this is to check out
what existing scripts are doing that are already successfully
submitting coverage results.

This one is on the VTK dashboard:
http://cdash.org/CDash/viewNotes.php?buildid=1880030

This one on CMake:
http://cdash.org/CDash/viewNotes.php?buildid=1879840

This one on ITK:
http://cdash.org/CDash/viewNotes.php?buildid=1879940

A simplest minimal example script that works with your example project
should be fairly easy to derive by distilling the coverage-related
elements from those scripts.

I think there's also a script in the ITK source tree that helps you
run coverage on just your own test and inspect the results locally. I
can't remember its whereabouts, but I bet you could find that too if
you search the ITK list archives.


> It'd be great if someone could add a simple example script that calls
> ctest_coverage to this example, along with the procedure to run it and
> inspect the result: http://www.cmake.org/Wiki/CTest/Coverage/Example


I agree. That would be great.


Hopefully, this is helpful, for now.
David C.


On Tue, Jan 3, 2012 at 10:18 AM, David Doria <daviddoria at gmail.com> wrote:
> On Tue, Jan 3, 2012 at 9:52 AM, David Cole <david.cole at kitware.com> wrote:
>>
>> To actually run the coverage testing, you need to have tests added with
>> add_test in your CMakeLists file, then you need to run a ctest -S script
>> that calls ctest_coverage, or use one of the predefined coverage dashboard
>> targets. (Use 'make help | grep Coverage' to see those.)
>
>
> When I run 'make help' from that example project's build dir I just see
>
> doriad at david-lab:~/build/Examples/CTest/Coverage$ make help
> The following are some of the valid targets for this Makefile:
> ... all (the default if no target is provided)
> ... clean
> ... depend
> ... Coverage
> ... edit_cache
> ... rebuild_cache
> ... test
> ... coverage.o
> ... coverage.i
> ... coverage.s
>
> I also ran 'make help | grep Coverage' in the VTK build dir (because I'd
> assume the dashboard targets you're talking about would be in a big project
> like VTK) but there is no output. Are these dashboard targets project
> specific? That is, if I'm working on a project that does not have a
> dashboard server, how would you see the coverage report?
>
> It'd be great if someone could add a simple example script that calls
> ctest_coverage to this example, along with the procedure to run it and
> inspect the result: http://www.cmake.org/Wiki/CTest/Coverage/Example
>
> David


More information about the CMake mailing list