summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2015-01-28 17:08:41 -0500
committerBrad King <brad.king@kitware.com>2015-02-03 10:40:58 -0500
commit8caa4e72abe4393914f4dcefd1621d3c86a7d139 (patch)
tree8049f1beaa5c0e461d50913c400c19f74c87155d /Tests
parent5c828cc89b4f78eceaf0402719cf5693a6627935 (diff)
downloadcmake-8caa4e72abe4393914f4dcefd1621d3c86a7d139.tar.gz
CTestCoverageCollectGCOV: Add test case
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt12
-rw-r--r--Tests/CTestCoverageCollectGCOV/fakegcov.cmake8
-rw-r--r--Tests/CTestCoverageCollectGCOV/test.cmake.in39
3 files changed, 59 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 3aecd9bfa9..1a79854735 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2269,6 +2269,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
PASS_REGULAR_EXPRESSION "Upload\\.xml")
configure_file(
+ "${CMake_SOURCE_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake"
+ @ONLY ESCAPE_QUOTES)
+ add_test(CTestCoverageCollectGCOV ${CMAKE_CTEST_COMMAND}
+ -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")
+
+ configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
@ONLY ESCAPE_QUOTES)
diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
new file mode 100644
index 0000000000..e704f14cae
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
@@ -0,0 +1,8 @@
+foreach(I RANGE 0 ${CMAKE_ARGC})
+ if("${CMAKE_ARGV${I}}" MATCHES ".*\\.gcda")
+ 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")
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
new file mode 100644
index 0000000000..4bdcb10e41
--- /dev/null
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -0,0 +1,39 @@
+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_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+ctest_start(Experimental)
+ctest_configure()
+ctest_build()
+ctest_test()
+
+file(WRITE ${CTEST_BINARY_DIRECTORY}/CMakeFiles/echoargs.dir/echoargs.gcda
+"dummy
+")
+
+include(CTestCoverageCollectGCOV)
+set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar)
+ctest_coverage_collect_gcov(
+ TARBALL "${tar_file}"
+ SOURCE "${CTEST_SOURCE_DIRECTORY}"
+ BUILD "${CTEST_BINARY_DIRECTORY}"
+ GCOV_COMMAND "${CMAKE_COMMAND}"
+ 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})
+
+set(expected_out
+"Testing/CoverageInfo/echoargs.gcov
+Testing/CoverageInfo/data.json
+CMakeFiles/echoargs.dir/Labels.json
+")
+
+if("${out}" STREQUAL "${expected_out}")
+ message("PASSED with correct output: ${out}")
+else()
+ message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
+endif()