summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-10 14:01:44 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-10 14:24:50 (GMT)
commit30dda4941698f6b9dd292b4237b4eff187c80241 (patch)
tree6451f2c55d10d97df7a2bcc5064e5e2576c6013d /Tests
parentdd8e84a8facbea761d95dc91c15d8d21e848cd6f (diff)
downloadCMake-30dda4941698f6b9dd292b4237b4eff187c80241.zip
CMake-30dda4941698f6b9dd292b4237b4eff187c80241.tar.gz
CMake-30dda4941698f6b9dd292b4237b4eff187c80241.tar.bz2
Tests: Convert CTestTestSerialOrder to RunCMake.ctest_test case
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/CTestTestSerialOrder/CMakeLists.txt40
-rw-r--r--Tests/CTestTestSerialOrder/test.cmake31
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake15
-rw-r--r--Tests/RunCMake/ctest_test/SerialOrder-stdout.txt16
5 files changed, 31 insertions, 75 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 1ee45d6..ae065c8 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3095,10 +3095,6 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
)
- ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
- --output-on-failure -C "\${CTestTest_CONFIG}")
- set_property(TEST CTestTestSerialOrder PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
-
if(NOT BORLAND)
set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
diff --git a/Tests/CTestTestSerialOrder/CMakeLists.txt b/Tests/CTestTestSerialOrder/CMakeLists.txt
deleted file mode 100644
index d46d80e..0000000
--- a/Tests/CTestTestSerialOrder/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-
-project(CTestTestSerialOrder)
-
-set(TEST_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_output.txt")
-
-enable_testing()
-
-function(add_serial_order_test TEST_NAME)
- add_test(NAME ${TEST_NAME}
- COMMAND ${CMAKE_COMMAND}
- "-DTEST_OUTPUT_FILE=${TEST_OUTPUT_FILE}"
- "-DTEST_NAME=${TEST_NAME}"
- -P "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake"
- )
-
- if(ARGC GREATER 1)
- set_tests_properties(${TEST_NAME} PROPERTIES ${ARGN})
- endif()
-endfunction()
-
-add_serial_order_test(initialization COST 1000)
-add_serial_order_test(test1)
-add_serial_order_test(test2)
-add_serial_order_test(test3)
-add_serial_order_test(test4 DEPENDS test5)
-
-add_serial_order_test(test5)
-set_tests_properties(test5 PROPERTIES DEPENDS "test6;test7b;test7a")
-
-add_serial_order_test(test6 COST -2)
-add_serial_order_test(test7a COST -1)
-add_serial_order_test(test7b COST -1)
-add_serial_order_test(test8 COST 10)
-add_serial_order_test(test9 COST 20)
-add_serial_order_test(test10 COST 0)
-add_serial_order_test(test11)
-add_serial_order_test(test12 COST 0)
-
-add_serial_order_test(verification COST -1000)
diff --git a/Tests/CTestTestSerialOrder/test.cmake b/Tests/CTestTestSerialOrder/test.cmake
deleted file mode 100644
index 8479cae..0000000
--- a/Tests/CTestTestSerialOrder/test.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-list(APPEND EXPECTED_OUTPUT
- initialization
- test9
- test8
- test1
- test2
- test3
- test6
- test7a
- test7b
- test5
- test4
- test10
- test11
- test12
-)
-
-
-if("${TEST_NAME}" STREQUAL "initialization")
- file(WRITE ${TEST_OUTPUT_FILE} "${TEST_NAME}")
-
-elseif("${TEST_NAME}" STREQUAL "verification")
- file(READ ${TEST_OUTPUT_FILE} ACTUAL_OUTPUT)
- if(NOT "${ACTUAL_OUTPUT}" STREQUAL "${EXPECTED_OUTPUT}")
- message(FATAL_ERROR "Actual test order [${ACTUAL_OUTPUT}] differs from expected test order [${EXPECTED_OUTPUT}]")
- endif()
-
-else()
- file(APPEND ${TEST_OUTPUT_FILE} ";${TEST_NAME}")
-
-endif()
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index 4413a4d..54880b5 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -11,6 +11,21 @@ endfunction()
run_ctest_test(TestQuiet QUIET)
+set(CASE_CMAKELISTS_SUFFIX_CODE [[
+foreach(i RANGE 1 6)
+ add_test(NAME test${i} COMMAND ${CMAKE_COMMAND} -E true)
+endforeach()
+set_property(TEST test1 PROPERTY COST -2)
+set_property(TEST test2 PROPERTY COST -1)
+set_property(TEST test3 PROPERTY COST 0)
+set_property(TEST test4 PROPERTY COST 1)
+set_property(TEST test5 PROPERTY COST 2)
+set_property(TEST test6 PROPERTY COST 3)
+set_property(TEST test6 PROPERTY DEPENDS test1)
+]])
+run_ctest_test(SerialOrder INCLUDE test)
+unset(CASE_CMAKELISTS_SUFFIX_CODE)
+
# Tests for the 'Test Load' feature of ctest
#
# Spoof a load average value to make these tests more reliable.
diff --git a/Tests/RunCMake/ctest_test/SerialOrder-stdout.txt b/Tests/RunCMake/ctest_test/SerialOrder-stdout.txt
new file mode 100644
index 0000000..5f5a0bc
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/SerialOrder-stdout.txt
@@ -0,0 +1,16 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/SerialOrder-build
+ Start 2: test1
+1/6 Test #2: test1 ............................ Passed +[0-9.]+ sec
+ Start 7: test6
+2/6 Test #7: test6 ............................ Passed +[0-9.]+ sec
+ Start 6: test5
+3/6 Test #6: test5 ............................ Passed +[0-9.]+ sec
+ Start 5: test4
+4/6 Test #5: test4 ............................ Passed +[0-9.]+ sec
+ Start 4: test3
+5/6 Test #4: test3 ............................ Passed +[0-9.]+ sec
+ Start 3: test2
+6/6 Test #3: test2 ............................ Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 6