Skip to content

Commit

Permalink
fix(#8): add standard ccov excluded directories by default
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Aug 11, 2022
1 parent 0d9187e commit a8aabb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ if(ASAP_BUILD_TESTS)
include(GoogleSanitizers)
include(CodeCoverage)
# Enable this target when the project has test cases
# asap_add_code_coverage_all_targets( EXCLUDE */test/* *googlemock*
# *googletest* /usr/*)
# asap_add_code_coverage_all_targets()
include(Valgrind)

cpmaddpackage(
Expand Down
12 changes: 11 additions & 1 deletion cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang|GNU")
endfunction()

function(asap_add_code_coverage_all_targets)
add_code_coverage_all_targets(${ARGV})
# Add standard exclusion patterns for code coverage reports
if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
# For clang we'll be using llvm-cov which expect regex as input for
# exclusions
set(STANDARD_EXCLUDES '.*/test/.*' '.*/\.cache/CPM/.*' '/usr/.*')
else()
# For GNU however, we'll be using lcov which expects file patterns as
# input for excludions
set(STANDARD_EXCLUDES */test/* */.cache/CPM/* /usr/*)
endif()
add_code_coverage_all_targets(EXCLUDE ${STANDARD_EXCLUDES} ${ARGV})
endfunction()

else()
Expand Down

0 comments on commit a8aabb3

Please sign in to comment.