[Cmake-commits] CMake branch, next, updated. v3.2.1-1464-gdd42365

Nils Gladitz nilsgladitz at gmail.com
Sat Apr 4 06:25:40 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  dd42365d9a196cff86359e2e269b6619ad4acad4 (commit)
       via  9a544f2d987df940625465129a5f00bea01ad4eb (commit)
      from  c56158b2c4aa16e9cefe30efab1ad467f4e36260 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd42365d9a196cff86359e2e269b6619ad4acad4
commit dd42365d9a196cff86359e2e269b6619ad4acad4
Merge: c56158b 9a544f2
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Sat Apr 4 06:25:38 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Apr 4 06:25:38 2015 -0400

    Merge topic 'gcov-module-coverage-exclude' into next
    
    9a544f2d CTestCoverageCollectGCOV: Support CTEST_CUSTOM_COVERAGE_EXCLUDE


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a544f2d987df940625465129a5f00bea01ad4eb
commit 9a544f2d987df940625465129a5f00bea01ad4eb
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Apr 2 17:02:08 2015 +0200
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Sat Apr 4 12:25:15 2015 +0200

    CTestCoverageCollectGCOV: Support CTEST_CUSTOM_COVERAGE_EXCLUDE

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
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 5944d08..d9988b2 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2345,12 +2345,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake"
     @ONLY ESCAPE_QUOTES)
   add_test(CTestCoverageCollectGCOV ${CMAKE_CTEST_COMMAND}
+    -C \${CTEST_CONFIGURATION_TYPE}
     -S "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" -VV
     --output-log "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/testOut.log"
     )
   set_tests_properties(CTestCoverageCollectGCOV PROPERTIES
     PASS_REGULAR_EXPRESSION
-    "PASSED with correct output.*Testing/CoverageInfo/echoargs.gcov")
+    "PASSED with correct output.*Testing/CoverageInfo/main.cpp.gcov")
 
   configure_file(
     "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp
new file mode 100644
index 0000000..85e6cd8
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp
@@ -0,0 +1 @@
+void foo() {}
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt b/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt
new file mode 100644
index 0000000..ce6fac4
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 3.2)
+
+project(TestProject CXX)
+
+include(CTest)
+
+set(SOURCES
+  main.cpp
+  3rdparty/foo.cpp
+  extra/extra.cpp
+)
+
+add_executable(myexecutable ${SOURCES})
+
+set_property(SOURCE main.cpp APPEND PROPERTY LABELS SourceLabel)
+set_property(TARGET myexecutable APPEND PROPERTY LABELS TargetLabel)
+
+set(MYEXECUTABLE_INFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/myexecutable_info.cmake")
+
+file(WRITE "${MYEXECUTABLE_INFO_FILE}" "
+  set(TARGET myexecutable)
+  set(SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
+  set(SOURCES \"${SOURCES}\")
+")
+
+add_custom_command(TARGET myexecutable
+  POST_BUILD
+  COMMAND ${CMAKE_COMMAND}
+    "-DINFO_FILE=${MYEXECUTABLE_INFO_FILE}"
+    -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_compile_time_gcno.cmake"
+  VERBATIM
+)
+
+add_test(NAME mytest
+  COMMAND ${CMAKE_COMMAND}
+    "-DMYEXECUTABLE=$<TARGET_FILE:myexecutable>"
+    "-DTARGETDIR=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/myexecutable.dir"
+    -P "${CMAKE_CURRENT_SOURCE_DIR}/fake_run_time_gcda.cmake"
+)
+
+set_property(TEST mytest APPEND PROPERTY LABELS TestLabel)
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp
new file mode 100644
index 0000000..c3a2c12
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp
@@ -0,0 +1 @@
+void extra() {}
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake
new file mode 100644
index 0000000..881460b
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake
@@ -0,0 +1,7 @@
+include("${INFO_FILE}")
+
+foreach(source ${SOURCES})
+  file(WRITE "CMakeFiles/${TARGET}.dir/${source}.gcno"
+    "${SOURCE_DIR}/${source}"
+  )
+endforeach()
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake
new file mode 100644
index 0000000..26ce2bd
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake
@@ -0,0 +1,12 @@
+execute_process(COMMAND ${MYEXECUTABLE} RESULT_VARIABLE RESULT)
+
+if(NOT RESULT_VARIABLE STREQUAL "0")
+  message("Test failure")
+endif()
+
+file(GLOB_RECURSE gcno_files "${TARGETDIR}/*.gcno")
+
+foreach(gcno_file ${gcno_files})
+  string(REPLACE ".gcno" ".gcda" gcda_file "${gcno_file}")
+  configure_file(${gcno_file} ${gcda_file} COPYONLY)
+endforeach()
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp
new file mode 100644
index 0000000..237c8ce
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp
@@ -0,0 +1 @@
+int main() {}
diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
index e704f14..b0c3a9b 100644
--- a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
+++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
@@ -3,6 +3,12 @@ foreach(I RANGE 0 ${CMAKE_ARGC})
     set(gcda_file "${CMAKE_ARGV${I}}")
   endif()
 endforeach()
-get_filename_component(gcda_file ${gcda_file} NAME_WE)
-file(WRITE "${CMAKE_SOURCE_DIR}/${gcda_file}.gcov"
-"fake gcov file")
+
+get_filename_component(gcda_name ${gcda_file} NAME)
+string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}")
+
+file(STRINGS "${gcda_file}" source_file LIMIT_COUNT 1 ENCODING UTF-8)
+
+file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}"
+  "        -:    0:Source:${source_file}"
+)
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
index 4bdcb10..29f7e7f 100644
--- a/Tests/CTestCoverageCollectGCOV/test.cmake.in
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -1,16 +1,21 @@
 cmake_minimum_required(VERSION 2.8.12)
-set(CTEST_PROJECT_NAME "SmallAndFast")
-set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTest/SmallAndFast")
-set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV")
+set(CTEST_PROJECT_NAME "TestProject")
+set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/TestProject")
+set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV/TestProject")
 set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+
+ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
+
 ctest_start(Experimental)
 ctest_configure()
 ctest_build()
 ctest_test()
 
-file(WRITE ${CTEST_BINARY_DIRECTORY}/CMakeFiles/echoargs.dir/echoargs.gcda
-"dummy
-")
+list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
+	"/foo/something"
+	"/3rdparty/"
+	"/bar/somethingelse"
+)
 
 include(CTestCoverageCollectGCOV)
 set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar)
@@ -22,15 +27,21 @@ ctest_coverage_collect_gcov(
   GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake")
 
 execute_process(COMMAND
-      ${CMAKE_COMMAND} -E tar tf ${tar_file}
-      OUTPUT_VARIABLE out
-      WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
+  ${CMAKE_COMMAND} -E tar tf ${tar_file}
+  OUTPUT_VARIABLE out
+  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+string(REPLACE "\n" ";" out "${out}")
+list(SORT out)
 
 set(expected_out
-"Testing/CoverageInfo/echoargs.gcov
-Testing/CoverageInfo/data.json
-CMakeFiles/echoargs.dir/Labels.json
-")
+  CMakeFiles/myexecutable.dir/Labels.json
+  Testing/CoverageInfo/data.json
+  Testing/CoverageInfo/extra.cpp.gcov
+  Testing/CoverageInfo/main.cpp.gcov
+)
 
 if("${out}" STREQUAL "${expected_out}")
   message("PASSED with correct output: ${out}")

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list