summaryrefslogtreecommitdiffstats
path: root/Modules/CTestCoverageCollectGCOV.cmake
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2015-04-02 15:02:08 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2015-04-04 10:25:15 (GMT)
commit9a544f2d987df940625465129a5f00bea01ad4eb (patch)
tree5ef0b0cfd39cd226e5aa363290710f910bdd261d /Modules/CTestCoverageCollectGCOV.cmake
parentf707460e42949e4ca372bf23892a7d6fb9eb1b86 (diff)
downloadCMake-9a544f2d987df940625465129a5f00bea01ad4eb.zip
CMake-9a544f2d987df940625465129a5f00bea01ad4eb.tar.gz
CMake-9a544f2d987df940625465129a5f00bea01ad4eb.tar.bz2
CTestCoverageCollectGCOV: Support CTEST_CUSTOM_COVERAGE_EXCLUDE
Diffstat (limited to 'Modules/CTestCoverageCollectGCOV.cmake')
-rw-r--r--Modules/CTestCoverageCollectGCOV.cmake31
1 files changed, 30 insertions, 1 deletions
diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake
index 4519627..8659a69 100644
--- a/Modules/CTestCoverageCollectGCOV.cmake
+++ b/Modules/CTestCoverageCollectGCOV.cmake
@@ -147,8 +147,37 @@ function(ctest_coverage_collect_gcov)
\"Binary\": \"${binary_dir}\"
}")
# collect the gcov files
+ set(unfiltered_gcov_files)
+ file(GLOB_RECURSE unfiltered_gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov")
+
set(gcov_files)
- file(GLOB_RECURSE gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov")
+ foreach(gcov_file ${unfiltered_gcov_files})
+ file(STRINGS ${binary_dir}/${gcov_file} first_line LIMIT_COUNT 1 ENCODING UTF-8)
+
+ set(is_excluded false)
+ if(first_line MATCHES "^ -: 0:Source:(.*)$")
+ set(source_file ${CMAKE_MATCH_1})
+ elseif(NOT GCOV_QUIET)
+ message(STATUS "Could not determine source file corresponding to: ${gcov_file}")
+ endif()
+
+ foreach(exclude_entry ${CTEST_CUSTOM_COVERAGE_EXCLUDE})
+ if(source_file MATCHES "${exclude_entry}")
+ set(is_excluded true)
+
+ if(NOT GCOV_QUIET)
+ message("Excluding coverage for: ${source_file} which matches ${exclude_entry}")
+ endif()
+
+ break()
+ endif()
+ endforeach()
+
+ if(NOT is_excluded)
+ list(APPEND gcov_files ${gcov_file})
+ endif()
+ endforeach()
+
# tar up the coverage info with the same date so that the md5
# sum will be the same for the tar file independent of file time
# stamps