summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-06 18:22:01 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-06 21:14:04 (GMT)
commitca0a9def2e95ed92ce866faa3c70015b9ab6123d (patch)
tree01e5982c89f5ba3b80b5e4b93d6ce25978d04fd7 /Source/CTest
parent60433fc6e82267011ff8cb62feb7611c696c87c0 (diff)
downloadCMake-ca0a9def2e95ed92ce866faa3c70015b9ab6123d.zip
CMake-ca0a9def2e95ed92ce866faa3c70015b9ab6123d.tar.gz
CMake-ca0a9def2e95ed92ce866faa3c70015b9ab6123d.tar.bz2
ctest: Exit with failure when tests-from-file input is missing
If the options added by * commit 022f20f663 (ctest: add command line option to run the tests listed in a given file, 2023-11-29, v3.29.0-rc1~66^2~2) * commit dbacc1d5a8 (ctest: add command line option to exclude tests listed in a given file, 2023-11-30, v3.29.0-rc1~66^2~1) * commit 701029726f (ctest_test: add options INCLUDE_FROM_FILE and EXCLUDE_FROM_FILE, 2023-12-03, v3.29.0-rc1~66^2) are given a missing file, fail instead of ignoring it. Fixes: #25740
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx20
-rw-r--r--Source/CTest/cmCTestTestHandler.h4
2 files changed, 14 insertions, 10 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index dc16f66..ebb5073 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1845,11 +1845,15 @@ bool cmCTestTestHandler::GetListOfTests()
}
if (!this->TestListFile.empty()) {
- this->TestsToRunByName = this->ReadTestListFile(this->TestListFile);
+ if (!this->ReadTestListFile(this->TestListFile, this->TestsToRunByName)) {
+ return false;
+ }
}
if (!this->ExcludeTestListFile.empty()) {
- this->TestsToExcludeByName =
- this->ReadTestListFile(this->ExcludeTestListFile);
+ if (!this->ReadTestListFile(this->ExcludeTestListFile,
+ this->TestsToExcludeByName)) {
+ return false;
+ }
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -2020,11 +2024,10 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
}
}
-std::set<std::string> cmCTestTestHandler::ReadTestListFile(
- const std::string& testListFileName) const
+bool cmCTestTestHandler::ReadTestListFile(
+ std::string const& testListFileName, std::set<std::string>& testNames) const
{
- std::set<std::string> testNames;
-
+ testNames.clear();
cmsys::ifstream ifs(testListFileName.c_str());
if (ifs) {
std::string line;
@@ -2043,9 +2046,10 @@ std::set<std::string> cmCTestTestHandler::ReadTestListFile(
"Problem reading test list file: "
<< testListFileName
<< " while generating list of tests to run." << std::endl);
+ return false;
}
- return testNames;
+ return true;
}
void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml,
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 84e6098..e9c964b 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -341,8 +341,8 @@ private:
std::string GetTestStatus(cmCTestTestResult const&);
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
- std::set<std::string> ReadTestListFile(
- const std::string& testListFileName) const;
+ bool ReadTestListFile(std::string const& testListFileName,
+ std::set<std::string>& testNames) const;
std::vector<std::string> CustomPreTest;
std::vector<std::string> CustomPostTest;