Skip to content
Snippets Groups Projects
Commit 84db68b0 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add toggle for code coverage

parent fd9a9f4f
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,11 @@ include_guard ()
This uses catch2 and FakeIt for the unit testing and mocking respectively.
The macro exposes the option `IHTA_COMMON_ENABLE_CODE_COVERAGE` which can
disable the code coverage by setting it to `OFF`. This can also be done by
adding `set(IHTA_COMMON_ENABLE_CODE_COVERAGE OFF)` before including the
IHTACMakeCommon library.
::
ihta_add_test(
......@@ -45,6 +50,8 @@ include_guard ()
#]=======================================================================]
macro (ihta_add_test)
option (IHTA_COMMON_ENABLE_CODE_COVERAGE "Set to false to disable code coverage reporting" ON)
set (options)
set (oneValueArgs NAME TEST_TARGET IDE_FOLDER)
set (multiValueArgs SOURCES COV_SOURCES)
......@@ -73,20 +80,22 @@ macro (ihta_add_test)
DOWNLOAD_ONLY ON
)
find_program (OPENCPPCOVERAGE OpenCppCoverage)
if (IHTA_COMMON_ENABLE_CODE_COVERAGE)
find_program (OPENCPPCOVERAGE OpenCppCoverage)
if (OPENCPPCOVERAGE)
CPMAddPackage (
NAME cpp_coverage
GITHUB_REPOSITORY ekcoh/cpp-coverage
GIT_TAG master
OPTIONS "CPP_COVERAGE_ENABLE_COV_COMMANDS ON"
)
# TODO set output types with quotes -> does not work :(
if (OPENCPPCOVERAGE)
CPMAddPackage (
NAME cpp_coverage
GITHUB_REPOSITORY ekcoh/cpp-coverage
GIT_TAG master
OPTIONS "CPP_COVERAGE_ENABLE_COV_COMMANDS ON"
)
# TODO set output types with quotes -> does not work :(
# unset(CPP_COVERAGE_REPORT_TYPE CACHE)
# unset(CPP_COVERAGE_REPORT_TYPE CACHE)
# set ( CPP_COVERAGE_REPORT_TYPE "\"Html;Badges\"" CACHE STRING "Report type passed to report tool via --reporttype argument" )
# set ( CPP_COVERAGE_REPORT_TYPE "\"Html;Badges\"" CACHE STRING "Report type passed to report tool via --reporttype argument" )
endif ()
endif ()
# Add the test executable
......@@ -100,7 +109,7 @@ macro (ihta_add_test)
set_property (TARGET ${IHTA_ADD_TEST_NAME} PROPERTY FOLDER "UnitTest/${IHTA_ADD_TEST_IDE_FOLDER}")
if (OPENCPPCOVERAGE)
if (OPENCPPCOVERAGE AND IHTA_COMMON_ENABLE_CODE_COVERAGE)
if (DEFINED IHTA_ADD_TEST_TEST_TARGET)
get_target_property (IHTA_ADD_TEST_TEST_TARGET_SOURCE_DIR ${IHTA_ADD_TEST_TEST_TARGET} SOURCE_DIR)
list (APPEND IHTA_ADD_TEST_COV_SOURCES "${IHTA_ADD_TEST_TEST_TARGET_SOURCE_DIR}/include"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment