summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-04-07 12:57:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-04-07 12:57:41 (GMT)
commit7d5a0f5f60b9ba60c90a43c42f157c658319e6ef (patch)
tree473877af34eb7500276d9c3f29111092156f2977 /Modules
parentcdce3cc902fee88250bc7e04e2ff7424fb2962e6 (diff)
parent8ea1b0df58a65092a8c82cb5491f6d0af08ba8e7 (diff)
downloadCMake-7d5a0f5f60b9ba60c90a43c42f157c658319e6ef.zip
CMake-7d5a0f5f60b9ba60c90a43c42f157c658319e6ef.tar.gz
CMake-7d5a0f5f60b9ba60c90a43c42f157c658319e6ef.tar.bz2
Merge topic 'branch_coverage_glob'
8ea1b0df CTestCoverageCollectGCOV: Improve documentation 425d7646 CTestCoverageCollectGCOV: Honor CTEST_EXTRA_COVERAGE_GLOB
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CTestCoverageCollectGCOV.cmake78
1 files changed, 70 insertions, 8 deletions
diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake
index f31e432..7df9666 100644
--- a/Modules/CTestCoverageCollectGCOV.cmake
+++ b/Modules/CTestCoverageCollectGCOV.cmake
@@ -2,14 +2,19 @@
# CTestCoverageCollectGCOV
# ------------------------
#
-# This module provides the function ``ctest_coverage_collect_gcov``.
-# The function will run gcov on the .gcda files in a binary tree and then
-# package all of the .gcov files into a tar file with a data.json that
-# contains the source and build directories for CDash to use in parsing
-# the coverage data. In addtion the Labels.json files for targets that
-# have coverage information are also put in the tar file for CDash to
-# asign the correct labels. This file can be sent to a CDash server for
-# display with the
+# This module provides the ``ctest_coverage_collect_gcov`` function.
+#
+# This function runs gcov on all .gcda files found in the binary tree
+# and packages the resulting .gcov files into a tar file.
+# This tarball also contains the following:
+#
+# * *data.json* defines the source and build directories for use by CDash.
+# * *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the
+# source files.
+# * The *uncovered* directory holds any uncovered files found by
+# :variable:`CTEST_EXTRA_COVERAGE_GLOB`.
+#
+# After generating this tar file, it can be sent to CDash for display with the
# :command:`ctest_submit(CDASH_UPLOAD)` command.
#
# .. command:: cdash_coverage_collect_gcov
@@ -172,6 +177,21 @@ function(ctest_coverage_collect_gcov)
set(unfiltered_gcov_files)
file(GLOB_RECURSE unfiltered_gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov")
+ # if CTEST_EXTRA_COVERAGE_GLOB was specified we search for files
+ # that might be uncovered
+ if (DEFINED CTEST_EXTRA_COVERAGE_GLOB)
+ set(uncovered_files)
+ foreach(search_entry IN LISTS CTEST_EXTRA_COVERAGE_GLOB)
+ if(NOT GCOV_QUIET)
+ message("Add coverage glob: ${search_entry}")
+ endif()
+ file(GLOB_RECURSE matching_files "${source_dir}/${search_entry}")
+ if (matching_files)
+ list(APPEND uncovered_files "${matching_files}")
+ endif()
+ endforeach()
+ endif()
+
set(gcov_files)
foreach(gcov_file ${unfiltered_gcov_files})
file(STRINGS ${binary_dir}/${gcov_file} first_line LIMIT_COUNT 1 ENCODING UTF-8)
@@ -195,20 +215,62 @@ function(ctest_coverage_collect_gcov)
endif()
endforeach()
+ get_filename_component(resolved_source_file "${source_file}" ABSOLUTE)
+ foreach(uncovered_file IN LISTS uncovered_files)
+ get_filename_component(resolved_uncovered_file "${uncovered_file}" ABSOLUTE)
+ if (resolved_uncovered_file STREQUAL resolved_source_file)
+ list(REMOVE_ITEM uncovered_files "${uncovered_file}")
+ endif()
+ endforeach()
+
if(NOT is_excluded)
list(APPEND gcov_files ${gcov_file})
endif()
endforeach()
+ foreach (uncovered_file ${uncovered_files})
+ # Check if this uncovered file should be excluded.
+ set(is_excluded false)
+ foreach(exclude_entry IN LISTS CTEST_CUSTOM_COVERAGE_EXCLUDE)
+ if(uncovered_file MATCHES "${exclude_entry}")
+ set(is_excluded true)
+ if(NOT GCOV_QUIET)
+ message("Excluding coverage for: ${uncovered_file} which matches ${exclude_entry}")
+ endif()
+ break()
+ endif()
+ endforeach()
+ if(is_excluded)
+ continue()
+ endif()
+
+ # Copy from source to binary dir, preserving any intermediate subdirectories.
+ get_filename_component(filename "${uncovered_file}" NAME)
+ get_filename_component(relative_path "${uncovered_file}" DIRECTORY)
+ string(REPLACE "${source_dir}" "" relative_path "${relative_path}")
+ if (relative_path)
+ # Strip leading slash.
+ string(SUBSTRING "${relative_path}" 1 -1 relative_path)
+ endif()
+ file(COPY ${uncovered_file} DESTINATION ${binary_dir}/uncovered/${relative_path})
+ if(relative_path)
+ list(APPEND uncovered_files_for_tar uncovered/${relative_path}/${filename})
+ else()
+ list(APPEND uncovered_files_for_tar uncovered/${filename})
+ 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
string(REPLACE ";" "\n" gcov_files "${gcov_files}")
string(REPLACE ";" "\n" label_files "${label_files}")
+ string(REPLACE ";" "\n" uncovered_files_for_tar "${uncovered_files_for_tar}")
file(WRITE "${coverage_dir}/coverage_file_list.txt"
"${gcov_files}
${coverage_dir}/data.json
${label_files}
+${uncovered_files_for_tar}
")
if (GCOV_QUIET)