summaryrefslogtreecommitdiffstats
path: root/Tests
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 /Tests
parentf707460e42949e4ca372bf23892a7d6fb9eb1b86 (diff)
downloadCMake-9a544f2d987df940625465129a5f00bea01ad4eb.zip
CMake-9a544f2d987df940625465129a5f00bea01ad4eb.tar.gz
CMake-9a544f2d987df940625465129a5f00bea01ad4eb.tar.bz2
CTestCoverageCollectGCOV: Support CTEST_CUSTOM_COVERAGE_EXCLUDE
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt3
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp1
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/CMakeLists.txt41
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp1
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/fake_compile_time_gcno.cmake7
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/fake_run_time_gcda.cmake12
-rw-r--r--Tests/CTestCoverageCollectGCOV/TestProject/main.cpp1
-rw-r--r--Tests/CTestCoverageCollectGCOV/fakegcov.cmake12
-rw-r--r--Tests/CTestCoverageCollectGCOV/test.cmake.in37
9 files changed, 98 insertions, 17 deletions
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}")