summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKelly (KT) Thompson <kgt@lanl.gov>2020-04-22 17:10:31 (GMT)
committerBrad King <brad.king@kitware.com>2020-04-30 12:42:00 (GMT)
commit40ca6ef12536300b1ea5e06dea4d98833f4e267d (patch)
treeaa7c83b117ae40ebfc24826f21327f624059ddb6 /Tests
parent81e83510a01601d61b49df72a549de9bc4af718f (diff)
downloadCMake-40ca6ef12536300b1ea5e06dea4d98833f4e267d.zip
CMake-40ca6ef12536300b1ea5e06dea4d98833f4e267d.tar.gz
CMake-40ca6ef12536300b1ea5e06dea4d98833f4e267d.tar.bz2
CTestCoverageCollectGCOV: Add TARBALL_COMPRESSION option
For large projects, the default bzip2 compression of gcov data is prohibitively expensively (could take several hours). Introduce options that allow the consumer to choose between file size and compression time. Add a new optional argument `TARBALL_COMPRESSION` for the macro `ctest_coverage_collect_gcov`. This option accepts the values `GZIP`, `BZIP2`, `XZ`, `FROM_EXT`, or an expression that evaluates to `FALSE`. The default value is `BZIP2` to preserve prior behavior. Fixes: #20593
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CTestCoverageCollectGCOV/test.cmake.in144
1 files changed, 136 insertions, 8 deletions
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
index 9fe25a7..1818888 100644
--- a/Tests/CTestCoverageCollectGCOV/test.cmake.in
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -8,6 +8,10 @@ ctest_configure()
ctest_build()
ctest_test()
+#------------------------------------------------------------------------------#
+# Common setup for all tests.
+#------------------------------------------------------------------------------#
+
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
"/foo/something"
"/3rdparty/"
@@ -15,15 +19,118 @@ list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
"/CMakeFiles/"
)
list(APPEND CTEST_EXTRA_COVERAGE_GLOB "*.cpp")
-
include(CTestCoverageCollectGCOV)
+set(expected_out
+ CMakeFiles/myexecutable.dir/Labels.json
+ Testing/CoverageInfo/data.json
+ Testing/CoverageInfo/extra.cpp.gcov
+ Testing/CoverageInfo/main.cpp.gcov
+ uncovered/extra/uncovered1.cpp
+ uncovered/uncovered2.cpp
+)
+
+#------------------------------------------------------------------------------#
+# Test 1: with standard arguments
+#------------------------------------------------------------------------------#
+
+set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tbz)
+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")
+file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered")
+
+execute_process(COMMAND
+ ${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)
+
+if("${out}" STREQUAL "${expected_out}")
+ message("PASSED with correct output: ${out}")
+else()
+ message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
+endif()
+
+#------------------------------------------------------------------------------#
+# Test 2: with optional argument: TARBALL_COMPRESSION "GZIP"
+#------------------------------------------------------------------------------#
+
+set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tgz)
+ctest_coverage_collect_gcov(
+ TARBALL "${tar_file}"
+ TARBALL_COMPRESSION "GZIP"
+ SOURCE "${CTEST_SOURCE_DIRECTORY}"
+ BUILD "${CTEST_BINARY_DIRECTORY}"
+ GCOV_COMMAND "${CMAKE_COMMAND}"
+ GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake")
+file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered")
+
+execute_process(COMMAND
+ ${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)
+
+if("${out}" STREQUAL "${expected_out}")
+ message("PASSED with correct output: ${out}")
+else()
+ message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
+endif()
+
+#------------------------------------------------------------------------------#
+# Test 3: with optional argument: TARBALL_COMPRESSION "FROM_EXT"
+#------------------------------------------------------------------------------#
+
+set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.txz)
+ctest_coverage_collect_gcov(
+ TARBALL "${tar_file}"
+ TARBALL_COMPRESSION "FROM_EXT"
+ SOURCE "${CTEST_SOURCE_DIRECTORY}"
+ BUILD "${CTEST_BINARY_DIRECTORY}"
+ GCOV_COMMAND "${CMAKE_COMMAND}"
+ GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake")
+file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered")
+
+execute_process(COMMAND
+ ${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)
+
+if("${out}" STREQUAL "${expected_out}")
+ message("PASSED with correct output: ${out}")
+else()
+ message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
+endif()
+
+#------------------------------------------------------------------------------#
+# Test 4: with optional argument: TARBALL_COMPRESSION "FALSE"
+#------------------------------------------------------------------------------#
+
set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar)
ctest_coverage_collect_gcov(
TARBALL "${tar_file}"
+ TARBALL_COMPRESSION "FALSE"
SOURCE "${CTEST_SOURCE_DIRECTORY}"
BUILD "${CTEST_BINARY_DIRECTORY}"
GCOV_COMMAND "${CMAKE_COMMAND}"
GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake")
+file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered")
execute_process(COMMAND
${CMAKE_COMMAND} -E tar tf ${tar_file}
@@ -35,15 +142,36 @@ execute_process(COMMAND
string(REPLACE "\n" ";" out "${out}")
list(SORT out)
-set(expected_out
- CMakeFiles/myexecutable.dir/Labels.json
- Testing/CoverageInfo/data.json
- Testing/CoverageInfo/extra.cpp.gcov
- Testing/CoverageInfo/main.cpp.gcov
- uncovered/extra/uncovered1.cpp
- uncovered/uncovered2.cpp
+if("${out}" STREQUAL "${expected_out}")
+ message("PASSED with correct output: ${out}")
+else()
+ message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}")
+endif()
+
+#------------------------------------------------------------------------------#
+# Test 5: with optional argument: TARBALL_COMPRESSION "ZSTD"
+#------------------------------------------------------------------------------#
+
+set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.zstd)
+ctest_coverage_collect_gcov(
+ TARBALL "${tar_file}"
+ TARBALL_COMPRESSION "ZSTD"
+ SOURCE "${CTEST_SOURCE_DIRECTORY}"
+ BUILD "${CTEST_BINARY_DIRECTORY}"
+ GCOV_COMMAND "${CMAKE_COMMAND}"
+ GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake")
+file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered")
+
+execute_process(COMMAND
+ ${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)
+
if("${out}" STREQUAL "${expected_out}")
message("PASSED with correct output: ${out}")
else()