mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
ctest: Honor tests-from-file options with empty input
If the `--tests-from-file` input file is empty, no tests should run.
This commit is contained in:
@@ -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;
|
||||
@@ -944,16 +946,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;
|
||||
}
|
||||
}
|
||||
@@ -1845,13 +1847,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;
|
||||
}
|
||||
}
|
||||
@@ -2024,12 +2028,13 @@ 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);
|
||||
@@ -2039,17 +2044,14 @@ bool cmCTestTestHandler::ReadTestListFile(
|
||||
|
||||
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,
|
||||
|
||||
@@ -341,8 +341,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;
|
||||
@@ -363,8 +363,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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user