summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2023-11-29 21:51:00 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-25 17:37:16 (GMT)
commit022f20f6632c934169f440271cabe8c7e52cce6e (patch)
tree3bd6022853103fede5e82a0b15089327fbfa4b80 /Tests
parent5d1e689e6814283f3920cbb963fe22393e790eae (diff)
downloadCMake-022f20f6632c934169f440271cabe8c7e52cce6e.zip
CMake-022f20f6632c934169f440271cabe8c7e52cce6e.tar.gz
CMake-022f20f6632c934169f440271cabe8c7e52cce6e.tar.bz2
ctest: add command line option to run the tests listed in a given file
Add `--tests-from-file <filename>` to run only the tests listed in the given file. The test names must match exactly, no regexps or something. The listed tests can still be filtered with a regexp using -R. Issue: #25455
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt2
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt5
3 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index 1b8d0d9..96bef92 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -207,6 +207,23 @@ set_tests_properties(test1 PROPERTIES SKIP_REGULAR_EXPRESSION \"test1\")
endfunction()
run_SkipRegexFoundTest()
+
+function(run_TestsFromFileTest arg)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestsFromFile)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(Test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+add_test(Test2 \"${CMAKE_COMMAND}\" -E echo \"test2\")
+add_test(Test11 \"${CMAKE_COMMAND}\" -E echo \"test11\")
+")
+ run_cmake_command(TestsFromFile-${arg} ${CMAKE_CTEST_COMMAND} --${arg} ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt )
+endfunction()
+run_TestsFromFileTest(tests-from-file)
+
+
function(run_SerialFailed)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SerialFailed)
set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt
new file mode 100644
index 0000000..91f6504
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt
@@ -0,0 +1,2 @@
+Test1
+# Test11
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt
new file mode 100644
index 0000000..653d56c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt
@@ -0,0 +1,5 @@
+ +Start 1: Test1
+1/1 Test #1: Test1 ............................ Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++