summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-11 14:15:49 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-03-11 14:17:00 (GMT)
commit490533577683ccb786a17b47259726944cb6fffa (patch)
tree031217dba5b9e34f558c39464ff4bf51d1f5919d /Source/CTest
parentb27df13417efed35931bb0bac7e87833d0391e85 (diff)
parent170ec486014958c372df4c38e940d50b2c0dc0af (diff)
downloadCMake-490533577683ccb786a17b47259726944cb6fffa.zip
CMake-490533577683ccb786a17b47259726944cb6fffa.tar.gz
CMake-490533577683ccb786a17b47259726944cb6fffa.tar.bz2
Merge topic 'ctest-tests-from-file'
170ec48601 Help: Improve ctest tests-from-file documentation wording and wrapping 1a4837641e ctest: Remove unnecessary and ambiguous tests-from-file comment syntax d52c66bfb3 ctest: Honor tests-from-file options with empty input 8673264e25 Tests: Make ctest tests-from-file expected output more precise Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !9322
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx45
-rw-r--r--Source/CTest/cmCTestTestHandler.h8
2 files changed, 26 insertions, 27 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 62524af..957806a 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -347,6 +347,8 @@ void cmCTestTestHandler::Initialize()
this->ExcludeFixtureCleanupRegExp.clear();
this->TestListFile.clear();
this->ExcludeTestListFile.clear();
+ this->TestsToRunByName.reset();
+ this->TestsToExcludeByName.reset();
this->TestsToRunString.clear();
this->UseUnion = false;
@@ -943,16 +945,16 @@ bool cmCTestTestHandler::ComputeTestList()
}
}
- if (!this->TestsToRunByName.empty()) {
- if (this->TestsToRunByName.find(tp.Name) ==
- this->TestsToRunByName.end()) {
+ if (this->TestsToRunByName) {
+ if (this->TestsToRunByName->find(tp.Name) ==
+ this->TestsToRunByName->end()) {
continue;
}
}
- if (!this->TestsToExcludeByName.empty()) {
- if (this->TestsToExcludeByName.find(tp.Name) !=
- this->TestsToExcludeByName.end()) {
+ if (this->TestsToExcludeByName) {
+ if (this->TestsToExcludeByName->find(tp.Name) !=
+ this->TestsToExcludeByName->end()) {
continue;
}
}
@@ -1846,13 +1848,15 @@ bool cmCTestTestHandler::GetListOfTests()
}
if (!this->TestListFile.empty()) {
- if (!this->ReadTestListFile(this->TestListFile, this->TestsToRunByName)) {
+ this->TestsToRunByName = this->ReadTestListFile(this->TestListFile);
+ if (!this->TestsToRunByName) {
return false;
}
}
if (!this->ExcludeTestListFile.empty()) {
- if (!this->ReadTestListFile(this->ExcludeTestListFile,
- this->TestsToExcludeByName)) {
+ this->TestsToExcludeByName =
+ this->ReadTestListFile(this->ExcludeTestListFile);
+ if (!this->TestsToExcludeByName) {
return false;
}
}
@@ -2025,32 +2029,27 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
}
}
-bool cmCTestTestHandler::ReadTestListFile(
- std::string const& testListFileName, std::set<std::string>& testNames) const
+cm::optional<std::set<std::string>> cmCTestTestHandler::ReadTestListFile(
+ std::string const& testListFileName) const
{
- testNames.clear();
+ cm::optional<std::set<std::string>> result;
cmsys::ifstream ifs(testListFileName.c_str());
if (ifs) {
+ std::set<std::string> testNames;
std::string line;
while (cmSystemTools::GetLineFromStream(ifs, line)) {
- std::string trimmed = cmTrimWhitespace(line);
- if (trimmed.empty() || (trimmed[0] == '#')) {
- continue;
+ if (!line.empty()) {
+ testNames.insert(line);
}
-
- testNames.insert(trimmed);
}
- ifs.close();
- } else if (!this->CTest->GetShowOnly() &&
- !this->CTest->ShouldPrintLabels()) {
+ result = std::move(testNames);
+ } else {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Problem reading test list file: "
<< testListFileName
<< " while generating list of tests to run." << std::endl);
- return false;
}
-
- return true;
+ return result;
}
void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml,
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index e05b2d56..dd1bc59 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -342,8 +342,8 @@ private:
std::string GetTestStatus(cmCTestTestResult const&);
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
- bool ReadTestListFile(std::string const& testListFileName,
- std::set<std::string>& testNames) const;
+ cm::optional<std::set<std::string>> ReadTestListFile(
+ std::string const& testListFileName) const;
std::vector<std::string> CustomPreTest;
std::vector<std::string> CustomPostTest;
@@ -364,8 +364,8 @@ private:
cmsys::RegularExpression ExcludeTestsRegularExpression;
std::string TestListFile;
std::string ExcludeTestListFile;
- std::set<std::string> TestsToRunByName;
- std::set<std::string> TestsToExcludeByName;
+ cm::optional<std::set<std::string>> TestsToRunByName;
+ cm::optional<std::set<std::string>> TestsToExcludeByName;
std::string ResourceSpecFile;