summaryrefslogtreecommitdiffstats
path: root/Tests/CTestTestMemcheck/CMakeLists.txt
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2013-05-05 18:44:07 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2013-05-09 17:22:31 (GMT)
commitabf1df48fc966efc8c2d489acbea24dc0312c84c (patch)
treec4d7b7cf788b17ea97d1ae3f100008b70ab73dcc /Tests/CTestTestMemcheck/CMakeLists.txt
parentf4994223bb84bfe98e0113a8a5ccac67435c13d3 (diff)
downloadCMake-abf1df48fc966efc8c2d489acbea24dc0312c84c.zip
CMake-abf1df48fc966efc8c2d489acbea24dc0312c84c.tar.gz
CMake-abf1df48fc966efc8c2d489acbea24dc0312c84c.tar.bz2
Tests: remove code duplication in CTestTestMemCheck tests
The code for the tests is basically the same for all those subtests, so have one template and configure that for as many tests as possible to make it easier maintainable.
Diffstat (limited to 'Tests/CTestTestMemcheck/CMakeLists.txt')
-rw-r--r--Tests/CTestTestMemcheck/CMakeLists.txt53
1 files changed, 40 insertions, 13 deletions
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt
index d2f3a87..3d6d8f3 100644
--- a/Tests/CTestTestMemcheck/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/CMakeLists.txt
@@ -31,25 +31,52 @@ target_link_libraries(memcheck_fail CMakeLib)
set(NORMAL_CTEST_OUTPUT "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n.*\n-- Processing memory checking output: \nMemory checking results:\n")
set(BULLSEYE_MSG "(BullseyeCoverage[^\n]*\n)?")
-foreach (_test IN ITEMS Unknown NotExist
- DummyValgrind DummyValgrindPrePost
- DummyValgrindFailPre DummyValgrindFailPost
- DummyPurify DummyBC
- DummyValgrindIgnoreMemcheck)
- configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/${_test}/test.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${_test}/test.cmake"
- @ONLY ESCAPE_QUOTES)
- add_test(NAME CTestTestMemcheck${_test}
+function(gen_mc_test NAME CHECKER)
+ set(SUBTEST_NAME "${NAME}")
+ set(CHECKER_COMMAND "${CHECKER}")
+ foreach(_file IN ITEMS CMakeLists.txt CTestConfig.cmake test.cmake)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${_file}.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${_file}" @ONLY)
+ endforeach()
+ add_test(NAME CTestTestMemcheck${NAME}
COMMAND ${CMAKE_CTEST_COMMAND}
- -S "${CMAKE_CURRENT_BINARY_DIR}/${_test}/test.cmake" -V
- --output-log "${CMAKE_CURRENT_BINARY_DIR}/${_test}/testOutput.log"
+ -C $<CONFIGURATION>
+ -S "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake" -V
+ --output-log "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/testOutput.log"
-D PSEUDO_BC=$<TARGET_FILE:pseudo_BC>
-D PSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify>
-D PSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind>
-D ERROR_COMMAND=$<TARGET_FILE:memcheck_fail>
)
-endforeach ()
+endfunction(gen_mc_test)
+
+unset(CTEST_EXTRA_CONFIG)
+unset(CTEST_EXTRA_CODE)
+unset(CMAKELISTS_EXTRA_CODE)
+
+gen_mc_test(DummyPurify "\${PSEUDO_PURIFY}")
+gen_mc_test(DummyValgrind "\${PSEUDO_VALGRIND}")
+gen_mc_test(DummyBC "\${PSEUDO_BC}")
+
+set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")\nset(CTEST_CUSTOM_POST_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")")
+gen_mc_test(DummyValgrindPrePost "\${PSEUDO_VALGRIND}")
+
+set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_POST_MEMCHECK \"\${ERROR_COMMAND}\")")
+gen_mc_test(DummyValgrindFailPost "\${PSEUDO_VALGRIND}")
+
+set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${ERROR_COMMAND}\")")
+gen_mc_test(DummyValgrindFailPre "\${PSEUDO_VALGRIND}")
+
+unset(CTEST_EXTRA_CODE)
+set(CTEST_EXTRA_CONFIG "set(CTEST_CUSTOM_MEMCHECK_IGNORE RunCMakeAgain)\n")
+set(CMAKELISTS_EXTRA_CODE "add_test(NAME RunCMakeAgain COMMAND \"\${CMAKE_COMMAND}\" --version)")
+gen_mc_test(DummyValgrindIgnoreMemcheck "\${PSEUDO_VALGRIND}")
+
+unset(CTEST_EXTRA_CONFIG)
+unset(CMAKELISTS_EXTRA_CODE)
+gen_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe")
+
+gen_mc_test(Unknown "${CMAKE_COMMAND}")
string(REPLACE "\\" "\\\\" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND}")
string(REPLACE "(" "\\(" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}")