From 5b9bf5af8afdf0212c3f380f68d250f708867ed0 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Tue, 25 Nov 2014 09:15:53 +0100 Subject: [PATCH] Disable tests if a requirement is not met instead of aborting CMake. --- scripts/cmake/test/AddTest.cmake | 23 ++++++++++++----------- scripts/cmake/test/Test.cmake | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake index e84158d8315..10b5bf12a89 100644 --- a/scripts/cmake/test/AddTest.cmake +++ b/scripts/cmake/test/AddTest.cmake @@ -59,18 +59,18 @@ function (AddTest) # --- Implement wrappers --- - # check requirements + # check requirements, disable if not met if(AddTest_WRAPPER STREQUAL "time" AND NOT TIME_TOOL_PATH) - message(FATAL_ERROR "time-command is required for time wrapper but was not found!") + return() endif() if(AddTest_WRAPPER STREQUAL "memcheck" AND NOT VALGRIND_TOOL_PATH) - message(FATAL_ERROR "Valgrind is required for memcheck wrapper but was not found!") + return() endif() if(AddTest_WRAPPER STREQUAL "callgrind" AND NOT VALGRIND_TOOL_PATH) - message(FATAL_ERROR "Valgrind is required for callgrind wrapper but was not found!") + return() endif() if(AddTest_WRAPPER STREQUAL "mpirun" AND NOT MPIRUN_TOOL_PATH) - message(FATAL_ERROR "mpirun is required for mpirun wrapper but was not found!") + return() endif() if(AddTest_WRAPPER STREQUAL "time") @@ -86,19 +86,20 @@ function (AddTest) endif() # --- Implement testers --- - # check requirements + # check requirements, disable if not met if(AddTest_TESTER STREQUAL "diff" AND NOT DIFF_TOOL_PATH) - message(FATAL_ERROR "diff-command is required for diff tester but was not found!") + return() endif() if(AddTest_TESTER STREQUAL "numdiff" AND NOT NUMDIFF_TOOL_PATH) - message(FATAL_ERROR "numdiff-command is required for numdiff tester but was not found!") + return() endif() + if(AddTest_TESTER STREQUAL "memcheck" AND NOT GREP_TOOL_PATH) + return() + endif() + if((AddTest_TESTER STREQUAL "diff" OR AddTest_TESTER STREQUAL "numdiff") AND NOT AddTest_DIFF_DATA) message(FATAL_ERROR "AddTest(): ${AddTest_NAME} - no DIFF_DATA given!") endif() - if(AddTest_TESTER STREQUAL "memcheck" AND NOT GREP_TOOL_PATH) - message(FATAL_ERROR "grep-command is required for memcheck tester but was not found!") - endif() if(AddTest_TESTER STREQUAL "diff") set(SELECTED_DIFF_TOOL_PATH ${DIFF_TOOL_PATH}) diff --git a/scripts/cmake/test/Test.cmake b/scripts/cmake/test/Test.cmake index 35982ff7560..5c13b193e34 100644 --- a/scripts/cmake/test/Test.cmake +++ b/scripts/cmake/test/Test.cmake @@ -8,6 +8,28 @@ FIND_PROGRAM(BASH_TOOL_PATH bash) FIND_PROGRAM(VALGRIND_TOOL_PATH valgrind) FIND_PROGRAM(MPIRUN_TOOL_PATH mpirun) +if(NOT TIME_TOOL_PATH) + message(STATUS "time-command is required for time wrapper but was not found! All corresponding tests are disabled.") +endif() +if(NOT VALGRIND_TOOL_PATH) + message(STATUS "Valgrind is required for memcheck wrapper but was not found! All corresponding tests are disabled.") +endif() +if(NOT VALGRIND_TOOL_PATH) + message(STATUS "Valgrind is required for callgrind wrapper but was not found! All corresponding tests are disabled.") +endif() +if(NOT MPIRUN_TOOL_PATH) + message(STATUS "mpirun is required for mpirun wrapper but was not found! All corresponding tests are disabled.") +endif() +if(NOT DIFF_TOOL_PATH) + message(STATUS "diff-command is required for diff tester but was not found! All corresponding tests are disabled.") +endif() +if(NOT NUMDIFF_TOOL_PATH) + message(STATUS "numdiff-command is required for numdiff tester but was not found! All corresponding tests are disabled.") +endif() +if(NOT GREP_TOOL_PATH) + message(STATUS "grep-command is required for memcheck tester but was not found! All corresponding tests are disabled.") +endif() + ENABLE_TESTING() # Enable CTest # See http://www.vtk.org/Wiki/CMake/Testing_With_CTest for some customization options -- GitLab