diff options
author | Brad King <brad.king@kitware.com> | 2024-01-26 15:14:49 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-26 15:14:58 (GMT) |
commit | d9b9f630832174c2b6ee31d8a06f6e587ab2dd84 (patch) | |
tree | 2e9096991944408275534306f4d9573e75d4d83e /Tests | |
parent | 409ab01039dd3c8f5ae0df48a1ee1c356132a9bf (diff) | |
parent | 701029726f17759a84b963e2f318742a1761670a (diff) | |
download | CMake-d9b9f630832174c2b6ee31d8a06f6e587ab2dd84.zip CMake-d9b9f630832174c2b6ee31d8a06f6e587ab2dd84.tar.gz CMake-d9b9f630832174c2b6ee31d8a06f6e587ab2dd84.tar.bz2 |
Merge topic 'ctest-tests-from-file'
701029726f ctest_test: add options INCLUDE_FROM_FILE and EXCLUDE_FROM_FILE
dbacc1d5a8 ctest: add command line option to exclude tests listed in a given file
022f20f663 ctest: add command line option to run the tests listed in a given file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex <leha-bot@yandex.ru>
Merge-request: !9128
Diffstat (limited to 'Tests')
8 files changed, 62 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 1b8d0d9..c09fff8 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -207,6 +207,24 @@ 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) +run_TestsFromFileTest(exclude-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-exclude-from-file-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-from-file-stdout.txt new file mode 100644 index 0000000..96d8c3b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-from-file-stdout.txt @@ -0,0 +1,7 @@ + +Start 2: Test2 +1/2 Test #2: Test2 ............................ Passed +[0-9.]+ sec + +Start 3: Test11 +2/2 Test #3: Test11 ........................... Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 2 ++ 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 ++ 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 |