Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IHTACMakeCommon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IHTA
CMake
IHTACMakeCommon
Commits
84db68b0
Commit
84db68b0
authored
2 years ago
by
Pascal Palenda
Browse files
Options
Downloads
Patches
Plain Diff
Add toggle for code coverage
parent
fd9a9f4f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/IhtaAddTest.cmake
+21
-12
21 additions, 12 deletions
src/IhtaAddTest.cmake
with
21 additions
and
12 deletions
src/IhtaAddTest.cmake
+
21
−
12
View file @
84db68b0
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment