diff options
author | Janek Bevendorff <janek@jbev.net> | 2018-09-29 15:55:33 +0300 |
---|---|---|
committer | Janek Bevendorff <janek@jbev.net> | 2018-10-19 22:45:53 +0300 |
commit | 18b22834c1d9657ab98ca5160571e51837bb6366 (patch) | |
tree | 76b4c16ffc0559903e979e2686e92da2f37db771 /CMakeLists.txt | |
parent | b8d2d5d877a407477ade9c26809211c40367ed9f (diff) |
Update and fix test coverage report generation
Generation of unit test coverage reports used to be quite complicated
and required a lot of different settings, including a custom CMake
build type. This patch updates the coverage CMake module to only
require -DWITH_COVERAGE=ON to be set on a normal Debug build in order
to create a coverage target.
This patch also moves away from lcov in favor of gcovr, since lcov appears
to be broken in GCC 8. However, the routines for generating lcov reports
still exist, so provided lcov receives updates and there is sufficient
reason to switch back, it is easy to do so.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 41a6b9403..0f8a4b672 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,12 +204,6 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align") - - if(WITH_COVERAGE) - # Include code coverage, use with -DCMAKE_BUILD_TYPE=Coverage - include(CodeCoverage) - setup_target_for_coverage(kp_coverage "make test" coverage) - endif() endif() if(CMAKE_COMPILER_IS_GNUCC) @@ -291,6 +285,21 @@ if(WITH_TESTS) enable_testing() endif(WITH_TESTS) +if(WITH_COVERAGE) + # Include code coverage, use with -DCMAKE_BUILD_TYPE=Debug + include(CodeCoverage) + set(COVERAGE_GCOVR_EXCLUDES + "\\(.+/\\)?tests/.\\*" + ".\\*/moc_\\[^/\\]+\\.cpp" + ".\\*/ui_\\[^/\\]+\\.h" + "\\(.+/\\)?zxcvbn/.\\*") + append_coverage_compiler_flags() + setup_target_for_coverage_gcovr_html( + NAME coverage + EXECUTABLE $(MAKE) && $(MAKE) test + ) +endif() + include(CLangFormat) if(UNIX AND NOT APPLE) |