Skip to content

Commit

Permalink
Implement the coverage-html target for LLVM
Browse files Browse the repository at this point in the history
Also corrected some lcov path exclusions broken by the
recently-added `VERBATIM`.
  • Loading branch information
pcolby committed Oct 7, 2024
1 parent bae5a89 commit 086a070
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
coverage
COMMAND ${LLVM_PROFDATA} merge --output coverage.profdata "${LLVM_PROFILE_FILES}"
COMMAND ${LLVM_PROFDATA} show coverage.profdata
COMMAND ${LLVM_COV} report --instr-profile coverage.profdata
COMMAND ${LLVM_COV} export --format lcov --instr-profile coverage.profdata
"--object;$<JOIN:$<TARGET_OBJECTS:QtPokit>,;--object;>"
"$<$<TARGET_EXISTS:cli-lib>:--object;$<JOIN:$<TARGET_OBJECTS:cli-lib>,;--object;>>"
"$<$<TARGET_EXISTS:gui-lib>:--object;$<JOIN:$<TARGET_OBJECTS:gui-lib>,;--object;>>"
--sources "${LLVM_COV_SOURCES}"
--sources "${LLVM_COV_SOURCES}" > coverage.info
COMMAND_EXPAND_LISTS
COMMENT "Collating coverage data"
VERBATIM
Expand All @@ -40,32 +39,35 @@ endif()
if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
find_program(CODECOV_GCOV gcov)
find_program(CODECOV_LCOV lcov)
find_program(CODECOV_GENHTML genhtml)
if (CODECOV_LCOV)
message(STATUS "Found gcov ${CODECOV_GCOV}")
message(STATUS "Found lcov ${CODECOV_LCOV}")
add_custom_target(
coverage
COMMAND ${CODECOV_LCOV} --capture --directory . --gcov-tool ${CODECOV_GCOV} --output-file coverage.info
COMMAND ${CODECOV_LCOV} --list coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '/usr/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/.qt/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/.rcc/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/moc_*.cpp' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/mocs_compilation.cpp' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/qt/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/Qt/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info '*/test/*' --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info /usr/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */.qt/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */.rcc/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */moc_*.cpp --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */mocs_compilation.cpp --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */qt/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */Qt/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --ignore-errors unused --remove coverage.info */test/* --output-file coverage.info
COMMAND ${CODECOV_LCOV} --list coverage.info
COMMENT "Collating coverage data"
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
endif()

if (ENABLE_COVERAGE)
find_program(CODECOV_GENHTML genhtml)
if (CODECOV_GENHTML)
message(STATUS "Found genhtml ${CODECOV_GENHTML}")
add_custom_target(
coverage-html
COMMAND ${CODECOV_GENHTML} --output-directory coverage coverage.info
COMMAND ${CODECOV_GENHTML} --output-directory coverage --prefix ${PROJECT_SOURCE_DIR} coverage.info
COMMENT "Generating HTML coverage report"
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
Expand Down

0 comments on commit 086a070

Please sign in to comment.