mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 19:30:13 -06:00
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
This commit is contained in:
@@ -13,6 +13,8 @@ Perform the :ref:`CTest Test Step` as a :ref:`Dashboard Client`.
|
||||
[INCLUDE <include-regex>]
|
||||
[EXCLUDE_LABEL <label-exclude-regex>]
|
||||
[INCLUDE_LABEL <label-include-regex>]
|
||||
[EXCLUDE_FROM_FILE <filename>]
|
||||
[INCLUDE_FROM_FILE <filename>]
|
||||
[EXCLUDE_FIXTURE <regex>]
|
||||
[EXCLUDE_FIXTURE_SETUP <regex>]
|
||||
[EXCLUDE_FIXTURE_CLEANUP <regex>]
|
||||
@@ -72,6 +74,16 @@ The options are:
|
||||
Specify a regular expression matching test labels to include.
|
||||
Tests not matching this expression are excluded.
|
||||
|
||||
``EXCLUDE_FROM_FILE <filename>``
|
||||
.. versionadded:: 3.29
|
||||
|
||||
Do NOT run tests listed with their exact name in the given file.
|
||||
|
||||
``INCLUDE_FROM_FILE <filename>``
|
||||
.. versionadded:: 3.29
|
||||
|
||||
Only run the tests listed with their exact name in the given file.
|
||||
|
||||
``EXCLUDE_FIXTURE <regex>``
|
||||
.. versionadded:: 3.7
|
||||
|
||||
|
||||
@@ -4,3 +4,7 @@ ctest-tests-from-file
|
||||
* :manual:`ctest(1)` gained the :option:`--tests-from-file <ctest
|
||||
--tests-from-file>` and :option:`--exclude-from-file <ctest
|
||||
--exclude-from-file>` options to run or exclude tests named in a file.
|
||||
|
||||
* The :command:`ctest_test` command gained options
|
||||
``INCLUDE_FROM_FILE`` and ``EXCLUDE_FROM_FILE`` to run or exclude
|
||||
tests named in a file.
|
||||
|
||||
@@ -26,6 +26,8 @@ void cmCTestTestCommand::BindArguments()
|
||||
this->Bind("INCLUDE"_s, this->Include);
|
||||
this->Bind("EXCLUDE_LABEL"_s, this->ExcludeLabel);
|
||||
this->Bind("INCLUDE_LABEL"_s, this->IncludeLabel);
|
||||
this->Bind("EXCLUDE_FROM_FILE"_s, this->ExcludeTestsFromFile);
|
||||
this->Bind("INCLUDE_FROM_FILE"_s, this->IncludeTestsFromFile);
|
||||
this->Bind("EXCLUDE_FIXTURE"_s, this->ExcludeFixture);
|
||||
this->Bind("EXCLUDE_FIXTURE_SETUP"_s, this->ExcludeFixtureSetup);
|
||||
this->Bind("EXCLUDE_FIXTURE_CLEANUP"_s, this->ExcludeFixtureCleanup);
|
||||
@@ -80,6 +82,14 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
||||
if (!this->IncludeLabel.empty()) {
|
||||
handler->AddMultiOption("LabelRegularExpression", this->IncludeLabel);
|
||||
}
|
||||
|
||||
if (!this->ExcludeTestsFromFile.empty()) {
|
||||
handler->SetOption("ExcludeTestListFile", this->ExcludeTestsFromFile);
|
||||
}
|
||||
if (!this->IncludeTestsFromFile.empty()) {
|
||||
handler->SetOption("TestListFile", this->IncludeTestsFromFile);
|
||||
}
|
||||
|
||||
if (!this->ExcludeFixture.empty()) {
|
||||
handler->SetOption("ExcludeFixtureRegularExpression",
|
||||
this->ExcludeFixture);
|
||||
|
||||
@@ -51,6 +51,8 @@ protected:
|
||||
std::string Include;
|
||||
std::string ExcludeLabel;
|
||||
std::string IncludeLabel;
|
||||
std::string IncludeTestsFromFile;
|
||||
std::string ExcludeTestsFromFile;
|
||||
std::string ExcludeFixture;
|
||||
std::string ExcludeFixtureSetup;
|
||||
std::string ExcludeFixtureCleanup;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
+
|
||||
@@ -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
|
||||
+
|
||||
2
Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
Normal file
2
Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Test1
|
||||
# Test11
|
||||
Reference in New Issue
Block a user