summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2023-12-03 16:59:10 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-25 17:38:04 (GMT)
commit701029726f17759a84b963e2f318742a1761670a (patch)
tree50f7433fa86cb9a74bead4214cae34e44500a48e /Tests/RunCMake
parentdbacc1d5a8c189289fe651ed9db892d9639354c6 (diff)
downloadCMake-701029726f17759a84b963e2f318742a1761670a.zip
CMake-701029726f17759a84b963e2f318742a1761670a.tar.gz
CMake-701029726f17759a84b963e2f318742a1761670a.tar.bz2
ctest_test: add options INCLUDE_FROM_FILE and EXCLUDE_FROM_FILE
These options can be used to specify files which can be used to restrict the set of tests that will be executed. Fixes: #25455
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt5
-rw-r--r--Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt2
4 files changed, 30 insertions, 0 deletions
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index b1ec9ad..4413a4d 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -163,6 +163,22 @@ add_test(NAME NotRunTest COMMAND ${CMAKE_COMMAND} -E true)
endfunction()
run_stop_on_failure()
+
+# test include/exclude tests from file
+function(run_tests_from_file mode)
+ set(CASE_CTEST_TEST_ARGS ${mode} ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_test(NAME Test1 COMMAND ${CMAKE_COMMAND} -E true)
+add_test(NAME Test2 COMMAND ${CMAKE_COMMAND} -E true)
+add_test(NAME Test11 COMMAND ${CMAKE_COMMAND} -E true)
+ ]])
+
+ run_ctest(TestsFromFile-${mode})
+endfunction()
+run_tests_from_file(INCLUDE_FROM_FILE)
+run_tests_from_file(EXCLUDE_FROM_FILE)
+
+
# Make sure environment gets logged
function(run_environment)
set(ENV{BAD_ENVIRONMENT_VARIABLE} "Bad environment variable")
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt
new file mode 100644
index 0000000..29c2b7f
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt
@@ -0,0 +1,7 @@
+ +Start 3: Test2
+2/3 Test #3: Test2 ............................ Passed +[0-9.]+ sec
+ +Start 4: Test11
+3/3 Test #4: Test11 ........................... Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 3
++
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt
new file mode 100644
index 0000000..e3ca719
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt
@@ -0,0 +1,5 @@
+ +Start 2: Test1
+1/1 Test #2: Test1 ............................ Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt b/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
new file mode 100644
index 0000000..91f6504
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
@@ -0,0 +1,2 @@
+Test1
+# Test11