Skip to content
Snippets Groups Projects
Commit d11d637e authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Now builds coverage using gcovr.

Produces both text output and html report in ${CMAKE_BINARY_DIR}/coverage
parent a6b7379d
No related branches found
No related tags found
No related merge requests found
...@@ -132,7 +132,6 @@ include_directories(src/scheme) ...@@ -132,7 +132,6 @@ include_directories(src/scheme)
include_directories(src/experimental) include_directories(src/experimental)
# Pastis tests # Pastis tests
set(CATCH_MODULE_PATH "${PASTIS_SOURCE_DIR}/packages/Catch2") set(CATCH_MODULE_PATH "${PASTIS_SOURCE_DIR}/packages/Catch2")
...@@ -144,6 +143,35 @@ add_subdirectory("${CATCH_MODULE_PATH}") ...@@ -144,6 +143,35 @@ add_subdirectory("${CATCH_MODULE_PATH}")
add_subdirectory(tests) add_subdirectory(tests)
enable_testing() enable_testing()
# unit tests coverage
if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
find_program(GCOVR gcovr)
if(NOT GCOVR)
message(FATAL_ERROR "gcovr not found, cannot perform coverage.")
endif()
set(GCOVR_OPTIONS --object-directory="${PASTIS_BINARY_DIR}" -r "${PASTIS_SOURCE_DIR}/src" -e "${PASTIS_SOURCE_DIR}/src/experimental" -e "${PASTIS_SOURCE_DIR}/src/main.cpp")
add_custom_target(coverage
ALL
# COMMAND ${unit_test_EXECUTABLE}
COMMAND ${GCOVR} ${GCOVR_OPTIONS}
DEPENDS unit_tests pastis
COMMENT "Running gcovr to build coverage report."
)
add_custom_target(coverage-report
ALL
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PASTIS_BINARY_DIR}/coverage"
COMMAND ${CMAKE_COMMAND} -E make_directory "${PASTIS_BINARY_DIR}/coverage"
COMMAND ${GCOVR} ${GCOVR_OPTIONS} --html --html-details -o "${PASTIS_BINARY_DIR}/coverage/coverage.html"
DEPENDS coverage
COMMENT "Building coverage html report."
WORKING_DIRECTORY "${PASTIS_BINARY_DIR}"
)
endif()
# ----------------------------------------------------- # -----------------------------------------------------
link_libraries("-rdynamic") link_libraries("-rdynamic")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment