2015-01-29 01:08:41 +03:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2015-04-02 18:02:08 +03:00
|
|
|
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")
|
2015-01-29 01:08:41 +03:00
|
|
|
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
|
2015-04-02 18:02:08 +03:00
|
|
|
|
|
|
|
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
|
|
|
|
|
2015-01-29 01:08:41 +03:00
|
|
|
ctest_start(Experimental)
|
|
|
|
ctest_configure()
|
|
|
|
ctest_build()
|
|
|
|
ctest_test()
|
|
|
|
|
2015-04-02 18:02:08 +03:00
|
|
|
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
|
|
|
|
"/foo/something"
|
|
|
|
"/3rdparty/"
|
|
|
|
"/bar/somethingelse"
|
|
|
|
)
|
2015-01-29 01:08:41 +03:00
|
|
|
|
|
|
|
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
|
2015-04-02 18:02:08 +03:00
|
|
|
${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)
|
2015-01-29 01:08:41 +03:00
|
|
|
|
|
|
|
set(expected_out
|
2015-04-02 18:02:08 +03:00
|
|
|
CMakeFiles/myexecutable.dir/Labels.json
|
|
|
|
Testing/CoverageInfo/data.json
|
|
|
|
Testing/CoverageInfo/extra.cpp.gcov
|
|
|
|
Testing/CoverageInfo/main.cpp.gcov
|
|
|
|
)
|
2015-01-29 01:08:41 +03:00
|
|
|
|
|
|
|
if("${out}" STREQUAL "${expected_out}")
|
|
|
|
message("PASSED with correct output: ${out}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
|
|
|
|
endif()
|