summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx13
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx9
-rw-r--r--Source/CTest/cmCTestP4.cxx3
-rw-r--r--Source/CTest/cmCTestRunTest.cxx3
-rw-r--r--Source/CTest/cmCTestSVN.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx184
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx3
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx3
8 files changed, 74 insertions, 146 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 772fa47..d9dd931 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -1830,9 +1830,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
return 0;
}
std::map<std::string, std::string> fileMap;
- std::vector<std::string>::iterator fp = filesFullPath.begin();
- for (std::vector<std::string>::iterator f = files.begin(); f != files.end();
- ++f, ++fp) {
+ auto fp = filesFullPath.begin();
+ for (auto f = files.begin(); f != files.end(); ++f, ++fp) {
fileMap[*f] = *fp;
}
@@ -1870,7 +1869,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
this->StartCoverageLogXML(covLogXML);
count++; // move on one
}
- std::map<std::string, std::string>::iterator i = fileMap.find(file);
+ auto i = fileMap.find(file);
// if the file should be covered write out the header for that file
if (i != fileMap.end()) {
// we have a new file so count it in the output
@@ -2202,7 +2201,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
int cmCTestCoverageHandler::GetLabelId(std::string const& label)
{
- LabelIdMapType::iterator i = this->LabelIdMap.find(label);
+ auto i = this->LabelIdMap.find(label);
if (i == this->LabelIdMap.end()) {
int n = int(this->Labels.size());
this->Labels.push_back(label);
@@ -2273,7 +2272,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
std::string const& source)
{
- LabelMapType::const_iterator li = this->SourceLabels.find(source);
+ auto li = this->SourceLabels.find(source);
if (li != this->SourceLabels.end() && !li->second.empty()) {
xml.StartElement("Labels");
for (auto const& ls : li->second) {
@@ -2316,7 +2315,7 @@ bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source)
// The source is filtered out if it does not have any labels in
// common with the filter set.
std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str());
- LabelMapType::const_iterator li = this->SourceLabels.find(shortSrc);
+ auto li = this->SourceLabels.find(shortSrc);
if (li != this->SourceLabels.end()) {
return !this->IntersectsFilter(li->second);
}
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index d3020b5..cc0b4ed 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -23,8 +23,7 @@ cmCTestGenericHandler::~cmCTestGenericHandler() = default;
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
if (!value) {
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->Options.find(op);
+ auto remit = this->Options.find(op);
if (remit != this->Options.end()) {
this->Options.erase(remit);
}
@@ -39,8 +38,7 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
{
this->SetOption(op, value);
if (!value) {
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->PersistentOptions.find(op);
+ auto remit = this->PersistentOptions.find(op);
if (remit != this->PersistentOptions.end()) {
this->PersistentOptions.erase(remit);
}
@@ -62,8 +60,7 @@ void cmCTestGenericHandler::Initialize()
const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->Options.find(op);
+ auto remit = this->Options.find(op);
if (remit == this->Options.end()) {
return nullptr;
}
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 9bca7cb..08c850d 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -146,8 +146,7 @@ private:
cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
{
- std::map<std::string, cmCTestP4::User>::const_iterator it =
- Users.find(username);
+ auto it = Users.find(username);
if (it == Users.end()) {
std::vector<char const*> p4_users;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 23c6b0d..c5bb826 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -571,8 +571,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
void cmCTestRunTest::ComputeArguments()
{
this->Arguments.clear(); // reset because this might be a rerun
- std::vector<std::string>::const_iterator j =
- this->TestProperties->Args.begin();
+ auto j = this->TestProperties->Args.begin();
++j; // skip test name
// find the test executable
if (this->TestHandler->MemCheck) {
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 6d8077f..a945111 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -169,7 +169,7 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
slash = svninfo.URL.find('/', slash + 1)) {
// If the URL suffix is a prefix of at least one path then it is the base.
std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash));
- for (std::vector<Change>::const_iterator ci = changes.begin();
+ for (auto ci = changes.begin();
svninfo.Base.empty() && ci != changes.end(); ++ci) {
if (cmCTestSVNPathStarts(ci->Path, base)) {
svninfo.Base = base;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f67b11a..f0c5939 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -7,8 +7,8 @@
#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestMultiProcessHandler.h"
-#include "cmCommand.h"
#include "cmDuration.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -40,36 +40,42 @@
#include <time.h>
#include <utility>
-class cmExecutionStatus;
+namespace {
-class cmCTestSubdirCommand : public cmCommand
+class cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
+ cmCTestCommand(cmCTestTestHandler* testHandler)
+ : TestHandler(testHandler)
{
- auto c = cm::make_unique<cmCTestSubdirCommand>();
- c->TestHandler = this->TestHandler;
- return std::unique_ptr<cmCommand>(std::move(c));
}
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/) override;
+ virtual ~cmCTestCommand() = default;
+
+ bool operator()(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status)
+ {
+ cmMakefile& mf = status.GetMakefile();
+ std::vector<std::string> expandedArguments;
+ if (!mf.ExpandArguments(args, expandedArguments)) {
+ // There was an error expanding arguments. It was already
+ // reported, so we can skip this command without error.
+ return true;
+ }
+ return this->InitialPass(expandedArguments, status);
+ }
+
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status) = 0;
cmCTestTestHandler* TestHandler;
};
-bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/)
+bool cmCTestSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
@@ -90,8 +96,8 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
{
cmWorkingDirectory workdir(fname);
if (workdir.Failed()) {
- this->SetError("Failed to change directory to " + fname + " : " +
- std::strerror(workdir.GetLastResult()));
+ status.SetError("Failed to change directory to " + fname + " : " +
+ std::strerror(workdir.GetLastResult()));
return false;
}
const char* testFilename;
@@ -107,45 +113,21 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
}
fname += "/";
fname += testFilename;
- readit = this->Makefile->ReadDependentFile(fname);
+ readit = status.GetMakefile().ReadDependentFile(fname);
}
if (!readit) {
- std::string m = cmStrCat("Could not find include file: ", fname);
- this->SetError(m);
+ status.SetError(cmStrCat("Could not find include file: ", fname));
return false;
}
}
return true;
}
-class cmCTestAddSubdirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- auto c = cm::make_unique<cmCTestAddSubdirectoryCommand>();
- c->TestHandler = this->TestHandler;
- return std::unique_ptr<cmCommand>(std::move(c));
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/) override;
-
- cmCTestTestHandler* TestHandler;
-};
-
-bool cmCTestAddSubdirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus& /*unused*/)
+bool cmCTestAddSubdirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -171,28 +153,19 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
}
fname += "/";
fname += testFilename;
- readit = this->Makefile->ReadDependentFile(fname);
+ readit = status.GetMakefile().ReadDependentFile(fname);
}
if (!readit) {
- std::string m = cmStrCat("Could not find include file: ", fname);
- this->SetError(m);
+ status.SetError(cmStrCat("Could not find include file: ", fname));
return false;
}
return true;
}
-class cmCTestAddTestCommand : public cmCommand
+class cmCTestAddTestCommand : public cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- auto c = cm::make_unique<cmCTestAddTestCommand>();
- c->TestHandler = this->TestHandler;
- return std::unique_ptr<cmCommand>(std::move(c));
- }
+ using cmCTestCommand::cmCTestCommand;
/**
* This is called when the command is first encountered in
@@ -200,32 +173,22 @@ public:
*/
bool InitialPass(std::vector<std::string> const& /*args*/,
cmExecutionStatus& /*unused*/) override;
-
- cmCTestTestHandler* TestHandler;
};
bool cmCTestAddTestCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/)
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
return this->TestHandler->AddTest(args);
}
-class cmCTestSetTestsPropertiesCommand : public cmCommand
+class cmCTestSetTestsPropertiesCommand : public cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- auto c = cm::make_unique<cmCTestSetTestsPropertiesCommand>();
- c->TestHandler = this->TestHandler;
- return std::unique_ptr<cmCommand>(std::move(c));
- }
+ using cmCTestCommand::cmCTestCommand;
/**
* This is called when the command is first encountered in
@@ -233,8 +196,6 @@ public:
*/
bool InitialPass(std::vector<std::string> const& /*args*/,
cmExecutionStatus& /*unused*/) override;
-
- cmCTestTestHandler* TestHandler;
};
bool cmCTestSetTestsPropertiesCommand::InitialPass(
@@ -243,18 +204,10 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass(
return this->TestHandler->SetTestsProperties(args);
}
-class cmCTestSetDirectoryPropertiesCommand : public cmCommand
+class cmCTestSetDirectoryPropertiesCommand : public cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- auto c = cm::make_unique<cmCTestSetDirectoryPropertiesCommand>();
- c->TestHandler = this->TestHandler;
- return std::unique_ptr<cmCommand>(std::move(c));
- }
+ using cmCTestCommand::cmCTestCommand;
/**
* This is called when the command is first encountered in
@@ -262,8 +215,6 @@ public:
*/
bool InitialPass(std::vector<std::string> const& /*unused*/,
cmExecutionStatus& /*unused*/) override;
-
- cmCTestTestHandler* TestHandler;
};
bool cmCTestSetDirectoryPropertiesCommand::InitialPass(
@@ -324,6 +275,8 @@ inline int GetNextRealNumber(std::string const& in, double& val,
return 0;
}
+} // namespace
+
cmCTestTestHandler::cmCTestTestHandler()
{
this->UseUnion = false;
@@ -690,8 +643,7 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
for (std::string const& l : p.Labels) {
// first check to see if the current label is a subproject label
bool isSubprojectLabel = false;
- std::vector<std::string>::iterator subproject =
- std::find(subprojects.begin(), subprojects.end(), l);
+ auto subproject = std::find(subprojects.begin(), subprojects.end(), l);
if (subproject != subprojects.end()) {
isSubprojectLabel = true;
}
@@ -945,8 +897,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
FixtureDependencies fixtureSetups;
FixtureDependencies fixtureCleanups;
- for (ListOfTests::const_iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it) {
+ for (auto it = this->TestList.begin(); it != this->TestList.end(); ++it) {
const cmCTestTestProperties& p = *it;
for (std::string const& deps : p.FixturesSetup) {
@@ -1007,8 +958,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// cleanup tests depend on this test case later.
std::pair<FixtureDepsIterator, FixtureDepsIterator> setupRange =
fixtureSetups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator sIt = setupRange.first;
- sIt != setupRange.second; ++sIt) {
+ for (auto sIt = setupRange.first; sIt != setupRange.second; ++sIt) {
const std::string& setupTestName = sIt->second->Name;
tests[i].RequireSuccessDepends.insert(setupTestName);
if (!cmContains(tests[i].Depends, setupTestName)) {
@@ -1031,8 +981,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
!excludeSetupRegex.find(requiredFixtureName)) {
std::pair<FixtureDepsIterator, FixtureDepsIterator> fixtureRange =
fixtureSetups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator it = fixtureRange.first;
- it != fixtureRange.second; ++it) {
+ for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) {
ListOfTests::const_iterator lotIt = it->second;
const cmCTestTestProperties& p = *lotIt;
@@ -1063,8 +1012,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
!excludeCleanupRegex.find(requiredFixtureName)) {
std::pair<FixtureDepsIterator, FixtureDepsIterator> fixtureRange =
fixtureCleanups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator it = fixtureRange.first;
- it != fixtureRange.second; ++it) {
+ for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) {
ListOfTests::const_iterator lotIt = it->second;
const cmCTestTestProperties& p = *lotIt;
@@ -1112,8 +1060,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// This cleanup test could be part of the original test list that was
// passed in. It is then possible that no other test requires the
// fIt fixture, so we have to check for this.
- std::map<std::string, std::vector<size_t>>::const_iterator cIt =
- fixtureRequirements.find(fixture);
+ auto cIt = fixtureRequirements.find(fixture);
if (cIt != fixtureRequirements.end()) {
const std::vector<size_t>& indices = cIt->second;
for (size_t index : indices) {
@@ -1688,31 +1635,23 @@ void cmCTestTestHandler::GetListOfTests()
mf.AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType());
// Add handler for ADD_TEST
- auto newCom1 = cm::make_unique<cmCTestAddTestCommand>();
- newCom1->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("add_test", std::move(newCom1));
+ cm.GetState()->AddBuiltinCommand("add_test", cmCTestAddTestCommand(this));
// Add handler for SUBDIRS
- auto newCom2 = cm::make_unique<cmCTestSubdirCommand>();
- newCom2->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("subdirs", std::move(newCom2));
+ cm.GetState()->AddBuiltinCommand("subdirs", cmCTestSubdirCommand);
// Add handler for ADD_SUBDIRECTORY
- auto newCom3 = cm::make_unique<cmCTestAddSubdirectoryCommand>();
- newCom3->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("add_subdirectory", std::move(newCom3));
+ cm.GetState()->AddBuiltinCommand("add_subdirectory",
+ cmCTestAddSubdirectoryCommand);
// Add handler for SET_TESTS_PROPERTIES
- auto newCom4 = cm::make_unique<cmCTestSetTestsPropertiesCommand>();
- newCom4->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("set_tests_properties", std::move(newCom4));
+ cm.GetState()->AddBuiltinCommand("set_tests_properties",
+ cmCTestSetTestsPropertiesCommand(this));
// Add handler for SET_DIRECTORY_PROPERTIES
cm.GetState()->RemoveBuiltinCommand("set_directory_properties");
- auto newCom5 = cm::make_unique<cmCTestSetDirectoryPropertiesCommand>();
- newCom5->TestHandler = this;
cm.GetState()->AddBuiltinCommand("set_directory_properties",
- std::move(newCom5));
+ cmCTestSetDirectoryPropertiesCommand(this));
const char* testFilename;
if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
@@ -1819,8 +1758,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
std::sort(this->TestsToRun.begin(), this->TestsToRun.end(),
std::less<int>());
// remove duplicates
- std::vector<int>::iterator new_end =
- std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
+ auto new_end = std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
this->TestsToRun.erase(new_end, this->TestsToRun.end());
}
@@ -2257,8 +2195,7 @@ bool cmCTestTestHandler::SetTestsProperties(
// sort the array
std::sort(rt.Labels.begin(), rt.Labels.end());
// remove duplicates
- std::vector<std::string>::iterator new_end =
- std::unique(rt.Labels.begin(), rt.Labels.end());
+ auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end());
rt.Labels.erase(new_end, rt.Labels.end());
}
if (key == "MEASUREMENT") {
@@ -2337,8 +2274,7 @@ bool cmCTestTestHandler::SetDirectoryProperties(
// sort the array
std::sort(rt.Labels.begin(), rt.Labels.end());
// remove duplicates
- std::vector<std::string>::iterator new_end =
- std::unique(rt.Labels.begin(), rt.Labels.end());
+ auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end());
rt.Labels.erase(new_end, rt.Labels.end());
}
}
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index cd2bb1a..b3ef7d3 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -47,8 +47,7 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
{
// loop over the coverage data computed and remove all files
// that only have -1 or 0 for the lines.
- cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci =
- this->Coverage.TotalCoverage.begin();
+ auto ci = this->Coverage.TotalCoverage.begin();
while (ci != this->Coverage.TotalCoverage.end()) {
cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second;
bool nothing = true;
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index afd7dc3..596b72e 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -123,8 +123,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
std::string& filepath)
{
- std::map<std::string, std::string>::iterator i =
- this->RoutineToDirectory.find(routine);
+ auto i = this->RoutineToDirectory.find(routine);
if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;