mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-14 05:20:50 -05:00
cmCTestTestHandler: Consolidate File options into cmCTestTestOptions
This commit is contained in:
@@ -84,10 +84,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this->ExcludeTestsFromFile.empty()) {
|
if (!this->ExcludeTestsFromFile.empty()) {
|
||||||
handler->SetOption("ExcludeTestListFile", this->ExcludeTestsFromFile);
|
handler->TestOptions.ExcludeTestListFile = this->ExcludeTestsFromFile;
|
||||||
}
|
}
|
||||||
if (!this->IncludeTestsFromFile.empty()) {
|
if (!this->IncludeTestsFromFile.empty()) {
|
||||||
handler->SetOption("TestListFile", this->IncludeTestsFromFile);
|
handler->TestOptions.TestListFile = this->IncludeTestsFromFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->ExcludeFixture.empty()) {
|
if (!this->ExcludeFixture.empty()) {
|
||||||
@@ -115,7 +115,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
|||||||
handler->SetOption("ScheduleRandom", this->ScheduleRandom);
|
handler->SetOption("ScheduleRandom", this->ScheduleRandom);
|
||||||
}
|
}
|
||||||
if (!this->ResourceSpecFile.empty()) {
|
if (!this->ResourceSpecFile.empty()) {
|
||||||
handler->SetOption("ResourceSpecFile", this->ResourceSpecFile);
|
handler->TestOptions.ResourceSpecFile = this->ResourceSpecFile;
|
||||||
}
|
}
|
||||||
if (!this->StopTime.empty()) {
|
if (!this->StopTime.empty()) {
|
||||||
this->CTest->SetStopTime(this->StopTime);
|
this->CTest->SetStopTime(this->StopTime);
|
||||||
|
|||||||
@@ -286,9 +286,6 @@ cmCTestTestHandler::cmCTestTestHandler()
|
|||||||
|
|
||||||
this->LogFile = nullptr;
|
this->LogFile = nullptr;
|
||||||
|
|
||||||
// Support for JUnit XML output.
|
|
||||||
this->JUnitXMLFileName = "";
|
|
||||||
|
|
||||||
// Regular expressions to scan test output for custom measurements.
|
// Regular expressions to scan test output for custom measurements.
|
||||||
|
|
||||||
// Capture the whole section of test output from the first opening
|
// Capture the whole section of test output from the first opening
|
||||||
@@ -332,8 +329,6 @@ void cmCTestTestHandler::Initialize(cmCTest* ctest)
|
|||||||
this->UseExcludeRegExpFirst = false;
|
this->UseExcludeRegExpFirst = false;
|
||||||
this->IncludeLabelRegularExpressions.clear();
|
this->IncludeLabelRegularExpressions.clear();
|
||||||
this->ExcludeLabelRegularExpressions.clear();
|
this->ExcludeLabelRegularExpressions.clear();
|
||||||
this->TestListFile.clear();
|
|
||||||
this->ExcludeTestListFile.clear();
|
|
||||||
this->TestsToRunByName.reset();
|
this->TestsToRunByName.reset();
|
||||||
this->TestsToExcludeByName.reset();
|
this->TestsToExcludeByName.reset();
|
||||||
|
|
||||||
@@ -578,18 +573,6 @@ bool cmCTestTestHandler::ProcessOptions()
|
|||||||
if (!this->TestOptions.ExcludeRegularExpression.empty()) {
|
if (!this->TestOptions.ExcludeRegularExpression.empty()) {
|
||||||
this->UseExcludeRegExp();
|
this->UseExcludeRegExp();
|
||||||
}
|
}
|
||||||
cmValue val = this->GetOption("ResourceSpecFile");
|
|
||||||
if (val) {
|
|
||||||
this->ResourceSpecFile = *val;
|
|
||||||
}
|
|
||||||
val = this->GetOption("TestListFile");
|
|
||||||
if (val) {
|
|
||||||
this->TestListFile = val;
|
|
||||||
}
|
|
||||||
val = this->GetOption("ExcludeTestListFile");
|
|
||||||
if (val) {
|
|
||||||
this->ExcludeTestListFile = val;
|
|
||||||
}
|
|
||||||
this->SetRerunFailed(this->GetOption("RerunFailed").IsOn());
|
this->SetRerunFailed(this->GetOption("RerunFailed").IsOn());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1414,7 +1397,7 @@ bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
|||||||
tests[p.Index].Depends = depends;
|
tests[p.Index].Depends = depends;
|
||||||
properties[p.Index] = &p;
|
properties[p.Index] = &p;
|
||||||
}
|
}
|
||||||
parallel->SetResourceSpecFile(this->ResourceSpecFile);
|
parallel->SetResourceSpecFile(this->TestOptions.ResourceSpecFile);
|
||||||
if (!parallel->SetTests(std::move(tests), std::move(properties))) {
|
if (!parallel->SetTests(std::move(tests), std::move(properties))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1849,19 +1832,20 @@ bool cmCTestTestHandler::GetListOfTests()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cmValue specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE");
|
cmValue specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE");
|
||||||
if (this->ResourceSpecFile.empty() && specFile) {
|
if (this->TestOptions.ResourceSpecFile.empty() && specFile) {
|
||||||
this->ResourceSpecFile = *specFile;
|
this->TestOptions.ResourceSpecFile = *specFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->TestListFile.empty()) {
|
if (!this->TestOptions.TestListFile.empty()) {
|
||||||
this->TestsToRunByName = this->ReadTestListFile(this->TestListFile);
|
this->TestsToRunByName =
|
||||||
|
this->ReadTestListFile(this->TestOptions.TestListFile);
|
||||||
if (!this->TestsToRunByName) {
|
if (!this->TestsToRunByName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this->ExcludeTestListFile.empty()) {
|
if (!this->TestOptions.ExcludeTestListFile.empty()) {
|
||||||
this->TestsToExcludeByName =
|
this->TestsToExcludeByName =
|
||||||
this->ReadTestListFile(this->ExcludeTestListFile);
|
this->ReadTestListFile(this->TestOptions.ExcludeTestListFile);
|
||||||
if (!this->TestsToExcludeByName) {
|
if (!this->TestsToExcludeByName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2548,22 +2532,22 @@ bool cmCTestTestHandler::cmCTestTestResourceRequirement::operator!=(
|
|||||||
|
|
||||||
void cmCTestTestHandler::SetJUnitXMLFileName(const std::string& filename)
|
void cmCTestTestHandler::SetJUnitXMLFileName(const std::string& filename)
|
||||||
{
|
{
|
||||||
this->JUnitXMLFileName = filename;
|
this->TestOptions.JUnitXMLFileName = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestTestHandler::WriteJUnitXML()
|
bool cmCTestTestHandler::WriteJUnitXML()
|
||||||
{
|
{
|
||||||
if (this->JUnitXMLFileName.empty()) {
|
if (this->TestOptions.JUnitXMLFileName.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open new XML file for writing.
|
// Open new XML file for writing.
|
||||||
cmGeneratedFileStream xmlfile;
|
cmGeneratedFileStream xmlfile;
|
||||||
xmlfile.SetTempExt("tmp");
|
xmlfile.SetTempExt("tmp");
|
||||||
xmlfile.Open(this->JUnitXMLFileName);
|
xmlfile.Open(this->TestOptions.JUnitXMLFileName);
|
||||||
if (!xmlfile) {
|
if (!xmlfile) {
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Problem opening file: " << this->JUnitXMLFileName
|
"Problem opening file: " << this->TestOptions.JUnitXMLFileName
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ struct cmCTestTestOptions
|
|||||||
std::string ExcludeFixtureRegularExpression;
|
std::string ExcludeFixtureRegularExpression;
|
||||||
std::string ExcludeFixtureSetupRegularExpression;
|
std::string ExcludeFixtureSetupRegularExpression;
|
||||||
std::string ExcludeFixtureCleanupRegularExpression;
|
std::string ExcludeFixtureCleanupRegularExpression;
|
||||||
|
|
||||||
|
std::string TestListFile;
|
||||||
|
std::string ExcludeTestListFile;
|
||||||
|
std::string ResourceSpecFile;
|
||||||
|
std::string JUnitXMLFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \class cmCTestTestHandler
|
/** \class cmCTestTestHandler
|
||||||
@@ -365,13 +370,9 @@ private:
|
|||||||
std::vector<cmsys::RegularExpression> ExcludeLabelRegularExpressions;
|
std::vector<cmsys::RegularExpression> ExcludeLabelRegularExpressions;
|
||||||
cmsys::RegularExpression IncludeTestsRegularExpression;
|
cmsys::RegularExpression IncludeTestsRegularExpression;
|
||||||
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
||||||
std::string TestListFile;
|
|
||||||
std::string ExcludeTestListFile;
|
|
||||||
cm::optional<std::set<std::string>> TestsToRunByName;
|
cm::optional<std::set<std::string>> TestsToRunByName;
|
||||||
cm::optional<std::set<std::string>> TestsToExcludeByName;
|
cm::optional<std::set<std::string>> TestsToExcludeByName;
|
||||||
|
|
||||||
std::string ResourceSpecFile;
|
|
||||||
|
|
||||||
void RecordCustomTestMeasurements(cmXMLWriter& xml, std::string content);
|
void RecordCustomTestMeasurements(cmXMLWriter& xml, std::string content);
|
||||||
void CheckLabelFilter(cmCTestTestProperties& it);
|
void CheckLabelFilter(cmCTestTestProperties& it);
|
||||||
void CheckLabelFilterExclude(cmCTestTestProperties& it);
|
void CheckLabelFilterExclude(cmCTestTestProperties& it);
|
||||||
@@ -392,7 +393,5 @@ private:
|
|||||||
int RepeatCount = 1;
|
int RepeatCount = 1;
|
||||||
bool RerunFailed;
|
bool RerunFailed;
|
||||||
|
|
||||||
std::string JUnitXMLFileName;
|
|
||||||
|
|
||||||
friend class cmCTestTestCommand;
|
friend class cmCTestTestCommand;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1856,8 +1856,8 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName,
|
|||||||
this->Impl->ParallelLevelSetInCli = true;
|
this->Impl->ParallelLevelSetInCli = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetPersistentOptionIfNotEmpty(
|
this->Impl->TestOptions.ResourceSpecFile =
|
||||||
expandedPreset->Execution->ResourceSpecFile, "ResourceSpecFile");
|
expandedPreset->Execution->ResourceSpecFile;
|
||||||
|
|
||||||
if (expandedPreset->Execution->TestLoad) {
|
if (expandedPreset->Execution->TestLoad) {
|
||||||
auto testLoad = *expandedPreset->Execution->TestLoad;
|
auto testLoad = *expandedPreset->Execution->TestLoad;
|
||||||
@@ -2600,25 +2600,17 @@ int cmCTest::Run(std::vector<std::string> const& args)
|
|||||||
dashFC },
|
dashFC },
|
||||||
CommandArgument{ "--resource-spec-file", CommandArgument::Values::One,
|
CommandArgument{ "--resource-spec-file", CommandArgument::Values::One,
|
||||||
[this](std::string const& file) -> bool {
|
[this](std::string const& file) -> bool {
|
||||||
this->Impl->TestHandler.SetPersistentOption(
|
this->Impl->TestOptions.ResourceSpecFile = file;
|
||||||
"ResourceSpecFile", file);
|
return true;
|
||||||
this->Impl->MemCheckHandler.SetPersistentOption(
|
} },
|
||||||
"ResourceSpecFile", file);
|
CommandArgument{ "--tests-from-file", CommandArgument::Values::One,
|
||||||
|
[this](std::string const& file) -> bool {
|
||||||
|
this->Impl->TestOptions.TestListFile = file;
|
||||||
return true;
|
return true;
|
||||||
} },
|
} },
|
||||||
CommandArgument{
|
|
||||||
"--tests-from-file", CommandArgument::Values::One,
|
|
||||||
[this](std::string const& file) -> bool {
|
|
||||||
this->Impl->TestHandler.SetPersistentOption("TestListFile", file);
|
|
||||||
this->Impl->MemCheckHandler.SetPersistentOption("TestListFile", file);
|
|
||||||
return true;
|
|
||||||
} },
|
|
||||||
CommandArgument{ "--exclude-from-file", CommandArgument::Values::One,
|
CommandArgument{ "--exclude-from-file", CommandArgument::Values::One,
|
||||||
[this](std::string const& file) -> bool {
|
[this](std::string const& file) -> bool {
|
||||||
this->Impl->TestHandler.SetPersistentOption(
|
this->Impl->TestOptions.ExcludeTestListFile = file;
|
||||||
"ExcludeTestListFile", file);
|
|
||||||
this->Impl->MemCheckHandler.SetPersistentOption(
|
|
||||||
"ExcludeTestListFile", file);
|
|
||||||
return true;
|
return true;
|
||||||
} },
|
} },
|
||||||
CommandArgument{ "--schedule-random", CommandArgument::Values::Zero,
|
CommandArgument{ "--schedule-random", CommandArgument::Values::Zero,
|
||||||
@@ -3511,7 +3503,7 @@ void cmCTest::SetOutputLogFileName(const std::string& name)
|
|||||||
|
|
||||||
void cmCTest::SetOutputJUnitFileName(const std::string& name)
|
void cmCTest::SetOutputJUnitFileName(const std::string& name)
|
||||||
{
|
{
|
||||||
this->Impl->TestHandler.SetJUnitXMLFileName(name);
|
this->Impl->TestOptions.JUnitXMLFileName = name;
|
||||||
// Turn test output compression off.
|
// Turn test output compression off.
|
||||||
// This makes it easier to include test output in the resulting
|
// This makes it easier to include test output in the resulting
|
||||||
// JUnit XML report.
|
// JUnit XML report.
|
||||||
|
|||||||
Reference in New Issue
Block a user