Skip to content

Commit

Permalink
Update and fix test coverage report generation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phoerious committed Oct 19, 2018
1 parent b8d2d5d commit 18b2283
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 145 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 18b2283

Please sign in to comment.