summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/CTest/cmCTestBZR.cxx5
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.cxx12
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx23
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx91
-rw-r--r--Source/CTest/cmCTestCVS.cxx21
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx6
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx188
-rw-r--r--Source/CTest/cmCTestCurl.cxx22
-rw-r--r--Source/CTest/cmCTestGIT.cxx15
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx6
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx19
-rw-r--r--Source/CTest/cmCTestHG.cxx27
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx7
-rw-r--r--Source/CTest/cmCTestLaunch.cxx20
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx62
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx168
-rw-r--r--Source/CTest/cmCTestP4.cxx15
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.cxx5
-rw-r--r--Source/CTest/cmCTestRunTest.cxx58
-rw-r--r--Source/CTest/cmCTestSVN.cxx25
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx23
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx81
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx430
-rw-r--r--Source/CTest/cmCTestTestHandler.h10
-rw-r--r--Source/CTest/cmCTestUploadHandler.cxx10
-rw-r--r--Source/CTest/cmCTestVC.cxx5
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.cxx8
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx6
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx8
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx5
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx11
-rw-r--r--Source/CTest/cmProcess.cxx5
-rw-r--r--Source/cmCTest.cxx78
33 files changed, 606 insertions, 869 deletions
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 4c9c5caf56..de5b4da95a 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -373,9 +373,8 @@ bool cmCTestBZR::UpdateImpl()
bzr_update.push_back(this->CommandLineTool.c_str());
bzr_update.push_back("pull");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- bzr_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ bzr_update.push_back(arg.c_str());
}
bzr_update.push_back(this->URL.c_str());
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx
index beee53a13f..2eed8bed9f 100644
--- a/Source/CTest/cmCTestBatchTestHandler.cxx
+++ b/Source/CTest/cmCTestBatchTestHandler.cxx
@@ -29,10 +29,9 @@ void cmCTestBatchTestHandler::WriteBatchScript()
fout.open(this->Script.c_str());
fout << "#!/bin/sh\n";
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- this->WriteSrunArgs(i->first, fout);
- this->WriteTestCommand(i->first, fout);
+ for (auto const& t : this->Tests) {
+ this->WriteSrunArgs(t.first, fout);
+ this->WriteTestCommand(t.first, fout);
fout << "\n";
}
fout.flush();
@@ -80,9 +79,8 @@ void cmCTestBatchTestHandler::WriteTestCommand(int test, std::ostream& fout)
this->TestHandler->GenerateTestCommand(processArgs, test);
processArgs.push_back(command);
- for (std::vector<std::string>::iterator arg = processArgs.begin();
- arg != processArgs.end(); ++arg) {
- fout << *arg << " ";
+ for (std::string const& arg : processArgs) {
+ fout << arg << " ";
}
std::vector<std::string>::iterator i = args.begin();
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index f9ff2d70ff..aae3c63920 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -45,7 +45,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::string& cmakeOutString,
cmake* cm)
{
- unsigned int k;
std::vector<std::string> args;
args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir);
@@ -80,8 +79,8 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
args.push_back(btype);
}
- for (k = 0; k < this->BuildOptions.size(); ++k) {
- args.push_back(this->BuildOptions[k]);
+ for (std::string const& opt : this->BuildOptions) {
+ args.push_back(opt);
}
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
@@ -219,12 +218,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
// do the build
- std::vector<std::string>::iterator tarIt;
if (this->BuildTargets.empty()) {
this->BuildTargets.push_back("");
}
- for (tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
- ++tarIt) {
+ for (std::string const& tar : this->BuildTargets) {
double remainingTime = 0;
if (this->Timeout > 0) {
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
@@ -249,7 +246,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
config = "Debug";
}
int retVal = cm.GetGlobalGenerator()->Build(
- this->SourceDir, this->BinaryDir, this->BuildProject, *tarIt, output,
+ this->SourceDir, this->BinaryDir, this->BuildProject, tar, output,
this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
remainingTime);
out << output;
@@ -292,8 +289,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
<< this->TestCommand << "\n";
out << "tried to find it in these places:\n";
out << fullPath << "\n";
- for (unsigned int i = 0; i < failed.size(); ++i) {
- out << failed[i] << "\n";
+ for (std::string const& fail : failed) {
+ out << fail << "\n";
}
if (outstring) {
*outstring = out.str();
@@ -305,8 +302,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::vector<const char*> testCommand;
testCommand.push_back(fullPath.c_str());
- for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
- testCommand.push_back(this->TestCommandArgs[k].c_str());
+ for (std::string const& testCommandArg : this->TestCommandArgs) {
+ testCommand.push_back(testCommandArg.c_str());
}
testCommand.push_back(nullptr);
std::string outs;
@@ -317,8 +314,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmSystemTools::ChangeDirectory(this->BuildRunDir);
}
out << "Running test command: \"" << fullPath << "\"";
- for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
- out << " \"" << this->TestCommandArgs[k] << "\"";
+ for (std::string const& testCommandArg : this->TestCommandArgs) {
+ out << " \"" << testCommandArg << "\"";
}
out << "\n";
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 3762e13d64..361b43b3b7 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -350,18 +350,16 @@ int cmCTestBuildHandler::ProcessHandler()
this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
}
- // Pre-compile regular expressions objects for all regular expressions
- std::vector<std::string>::iterator it;
+// Pre-compile regular expressions objects for all regular expressions
#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
regexes.clear(); \
cmCTestOptionalLog(this->CTest, DEBUG, \
this << "Add " #regexes << std::endl, this->Quiet); \
- for (it = (strings).begin(); it != (strings).end(); ++it) { \
+ for (std::string const& s : (strings)) { \
cmCTestOptionalLog(this->CTest, DEBUG, \
- "Add " #strings ": " << *it << std::endl, \
- this->Quiet); \
- (regexes).push_back(it->c_str()); \
+ "Add " #strings ": " << s << std::endl, this->Quiet); \
+ (regexes).push_back(s.c_str()); \
}
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
this->ErrorMatchRegex);
@@ -426,27 +424,24 @@ int cmCTestBuildHandler::ProcessHandler()
double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start;
// Cleanups strings in the errors and warnings list.
- t_ErrorsAndWarningsVector::iterator evit;
if (!this->SimplifySourceDir.empty()) {
- for (evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end(); ++evit) {
- cmSystemTools::ReplaceString(evit->Text, this->SimplifySourceDir.c_str(),
+ for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
+ cmSystemTools::ReplaceString(evit.Text, this->SimplifySourceDir.c_str(),
"/.../");
- cmSystemTools::ReplaceString(evit->PreContext,
+ cmSystemTools::ReplaceString(evit.PreContext,
this->SimplifySourceDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(evit->PostContext,
+ cmSystemTools::ReplaceString(evit.PostContext,
this->SimplifySourceDir.c_str(), "/.../");
}
}
if (!this->SimplifyBuildDir.empty()) {
- for (evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end(); ++evit) {
- cmSystemTools::ReplaceString(evit->Text, this->SimplifyBuildDir.c_str(),
+ for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
+ cmSystemTools::ReplaceString(evit.Text, this->SimplifyBuildDir.c_str(),
"/.../");
- cmSystemTools::ReplaceString(evit->PreContext,
+ cmSystemTools::ReplaceString(evit.PreContext,
this->SimplifyBuildDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(evit->PostContext,
+ cmSystemTools::ReplaceString(evit.PostContext,
this->SimplifyBuildDir.c_str(), "/.../");
}
}
@@ -556,9 +551,8 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
}
// Copy the fragments into the final XML file.
- for (Fragments::const_iterator fi = fragments.begin(); fi != fragments.end();
- ++fi) {
- xml.FragmentFile(fi->c_str());
+ for (std::string const& f : fragments) {
+ xml.FragmentFile(f.c_str());
}
}
@@ -588,12 +582,11 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
xml.StartElement(cm->Error ? "Error" : "Warning");
xml.Element("BuildLogLine", cm->LogLine);
xml.Element("Text", cm->Text);
- std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
- for (rit = this->ErrorWarningFileLineRegex.begin();
- rit != this->ErrorWarningFileLineRegex.end(); ++rit) {
- cmsys::RegularExpression* re = &rit->RegularExpression;
+ for (cmCTestCompileErrorWarningRex& rit :
+ this->ErrorWarningFileLineRegex) {
+ cmsys::RegularExpression* re = &rit.RegularExpression;
if (re->find(cm->Text.c_str())) {
- cm->SourceFile = re->match(rit->FileIndex);
+ cm->SourceFile = re->match(rit.FileIndex);
// At this point we need to make this->SourceFile relative to
// the source root of the project, so cvs links will work
cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
@@ -609,7 +602,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
}
- cm->LineNumber = atoi(re->match(rit->LineIndex).c_str());
+ cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
break;
}
}
@@ -759,9 +752,8 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
fname += purpose;
fname += ".txt";
cmGeneratedFileStream fout(fname.c_str());
- for (std::vector<std::string>::const_iterator mi = matchers.begin();
- mi != matchers.end(); ++mi) {
- fout << *mi << "\n";
+ for (std::string const& m : matchers) {
+ fout << m << "\n";
}
}
@@ -777,18 +769,19 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
}
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ for (std::string const& arg : args) {
+ argv.push_back(arg.c_str());
}
argv.push_back(nullptr);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
this->Quiet);
- std::vector<const char*>::iterator ait;
- for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
+ for (char const* arg : argv) {
+ if (!arg) {
+ break;
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " \"" << *ait << "\"", this->Quiet);
+ " \"" << arg << "\"", this->Quiet);
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
this->Quiet);
@@ -1007,10 +1000,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
errorwarning.PostContext = "";
// Copy pre-context to report
- std::deque<std::string>::iterator pcit;
- for (pcit = this->PreContext.begin(); pcit != this->PreContext.end();
- ++pcit) {
- errorwarning.PreContext += *pcit + "\n";
+ for (std::string const& pc : this->PreContext) {
+ errorwarning.PreContext += pc + "\n";
}
this->PreContext.clear();
@@ -1082,8 +1073,6 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
this->Quiet);
- std::vector<cmsys::RegularExpression>::iterator it;
-
int warningLine = 0;
int errorLine = 0;
@@ -1092,9 +1081,8 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
if (!this->ErrorQuotaReached) {
// Errors
int wrxCnt = 0;
- for (it = this->ErrorMatchRegex.begin(); it != this->ErrorMatchRegex.end();
- ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
+ if (rx.find(data)) {
errorLine = 1;
cmCTestOptionalLog(this->CTest, DEBUG,
" Error Line: " << data << " (matches: "
@@ -1107,9 +1095,8 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
}
// Error exceptions
wrxCnt = 0;
- for (it = this->ErrorExceptionRegex.begin();
- it != this->ErrorExceptionRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
+ if (rx.find(data)) {
errorLine = 0;
cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: "
<< data << " (matches: "
@@ -1124,9 +1111,8 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
if (!this->WarningQuotaReached) {
// Warnings
int wrxCnt = 0;
- for (it = this->WarningMatchRegex.begin();
- it != this->WarningMatchRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
+ if (rx.find(data)) {
warningLine = 1;
cmCTestOptionalLog(this->CTest, DEBUG, " Warning Line: "
<< data << " (matches: "
@@ -1140,9 +1126,8 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
wrxCnt = 0;
// Warning exceptions
- for (it = this->WarningExceptionRegex.begin();
- it != this->WarningExceptionRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
+ if (rx.find(data)) {
warningLine = 0;
cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: "
<< data << " (matches: "
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index f2a9a85f4d..6eeb135fd5 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -92,9 +92,8 @@ bool cmCTestCVS::UpdateImpl()
cvs_update.push_back(this->CommandLineTool.c_str());
cvs_update.push_back("-z3");
cvs_update.push_back("update");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- cvs_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ cvs_update.push_back(arg.c_str());
}
cvs_update.push_back(nullptr);
@@ -242,12 +241,12 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
// Load revisions and write an entry for each file in this directory.
std::vector<Revision> revisions;
- for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
- std::string full = path + slash + fi->first;
+ for (auto const& fi : dir) {
+ std::string full = path + slash + fi.first;
// Load two real or unknown revisions.
revisions.clear();
- if (fi->second != PathUpdated) {
+ if (fi.second != PathUpdated) {
// For local modifications the current rev is unknown and the
// prior rev is the latest from cvs.
revisions.push_back(this->Unknown);
@@ -256,8 +255,8 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
revisions.resize(2, this->Unknown);
// Write the entry for this file with these revisions.
- File f(fi->second, &revisions[0], &revisions[1]);
- this->WriteXMLEntry(xml, path, fi->first, full, f);
+ File f(fi.second, &revisions[0], &revisions[1]);
+ this->WriteXMLEntry(xml, path, fi.first, full, f);
}
xml.EndElement(); // Directory
}
@@ -269,10 +268,8 @@ bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
" "
<< std::flush);
- for (std::map<std::string, Directory>::const_iterator di =
- this->Dirs.begin();
- di != this->Dirs.end(); ++di) {
- this->WriteXMLDirectory(xml, di->first, di->second);
+ for (auto const& d : this->Dirs) {
+ this->WriteXMLDirectory(xml, d.first, d.second);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index faa75d3827..c44b866054 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -79,11 +79,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += cmSystemTools::GetCMakeCommand();
cmakeConfigureCommand += "\"";
- std::vector<std::string>::const_iterator it;
- std::string option;
- for (it = options.begin(); it != options.end(); ++it) {
- option = *it;
-
+ for (std::string const& option : options) {
cmakeConfigureCommand += " \"";
cmakeConfigureCommand += option;
cmakeConfigureCommand += "\"";
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index e3d68c6ae7..5ae4ed54de 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -67,10 +67,8 @@ public:
bool StartProcess()
{
std::vector<const char*> args;
- for (std::vector<std::string>::iterator i =
- this->CommandLineStrings.begin();
- i != this->CommandLineStrings.end(); ++i) {
- args.push_back(i->c_str());
+ for (std::string const& cl : this->CommandLineStrings) {
+ args.push_back(cl.c_str());
}
args.push_back(nullptr); // null terminate
cmsysProcess_SetCommand(this->Process, &*args.begin());
@@ -136,10 +134,9 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
cmsys::Glob gl;
gl.FindFiles(logGlob);
std::vector<std::string> const& files = gl.GetFiles();
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- log << "Removing old coverage log: " << *fi << "\n";
- cmSystemTools::RemoveFile(*fi);
+ for (std::string const& f : files) {
+ log << "Removing old coverage log: " << f << "\n";
+ cmSystemTools::RemoveFile(f);
}
}
@@ -196,10 +193,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
return false;
}
- std::vector<cmsys::RegularExpression>::iterator sit;
- for (sit = this->CustomCoverageExcludeRegex.begin();
- sit != this->CustomCoverageExcludeRegex.end(); ++sit) {
- if (sit->find(file)) {
+ for (cmsys::RegularExpression& rx : this->CustomCoverageExcludeRegex) {
+ if (rx.find(file)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " File "
<< file << " is excluded in CTestCustom.ctest"
<< std::endl;
@@ -319,11 +314,9 @@ int cmCTestCoverageHandler::ProcessHandler()
// setup the regex exclude stuff
this->CustomCoverageExcludeRegex.clear();
- std::vector<std::string>::iterator rexIt;
- for (rexIt = this->CustomCoverageExclude.begin();
- rexIt != this->CustomCoverageExclude.end(); ++rexIt) {
+ for (std::string const& rex : this->CustomCoverageExclude) {
this->CustomCoverageExcludeRegex.push_back(
- cmsys::RegularExpression(rexIt->c_str()));
+ cmsys::RegularExpression(rex.c_str()));
}
if (this->HandleBullseyeCoverage(&cont)) {
@@ -414,7 +407,6 @@ int cmCTestCoverageHandler::ProcessHandler()
return -1;
}
this->StartCoverageLogXML(covLogXML);
- cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator fileIterator;
int cnt = 0;
long total_tested = 0;
long total_untested = 0;
@@ -430,8 +422,7 @@ int cmCTestCoverageHandler::ProcessHandler()
std::vector<std::string> errorsWhileAccumulating;
file_count = 0;
- for (fileIterator = cont.TotalCoverage.begin();
- fileIterator != cont.TotalCoverage.end(); ++fileIterator) {
+ for (auto const& file : cont.TotalCoverage) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
file_count++;
@@ -443,7 +434,7 @@ int cmCTestCoverageHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
}
- const std::string fullFileName = fileIterator->first;
+ const std::string fullFileName = file.first;
bool shouldIDoCoverage = this->ShouldIDoCoverage(
fullFileName.c_str(), sourceDir.c_str(), binaryDir.c_str());
if (!shouldIDoCoverage) {
@@ -478,7 +469,7 @@ int cmCTestCoverageHandler::ProcessHandler()
std::string shortFileName =
this->CTest->GetShortPathToFile(fullFileName.c_str());
const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov =
- fileIterator->second;
+ file.second;
covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName);
covLogXML.Attribute("FullPath", shortFileName);
@@ -554,14 +545,13 @@ int cmCTestCoverageHandler::ProcessHandler()
}
// Handle all the files in the extra coverage globs that have no cov data
- for (std::set<std::string>::iterator i = uncovered.begin();
- i != uncovered.end(); ++i) {
- std::string fileName = cmSystemTools::GetFilenameName(*i);
- std::string fullPath = cont.SourceDir + "/" + *i;
+ for (std::string const& u : uncovered) {
+ std::string fileName = cmSystemTools::GetFilenameName(u);
+ std::string fullPath = cont.SourceDir + "/" + u;
covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName);
- covLogXML.Attribute("FullPath", *i);
+ covLogXML.Attribute("FullPath", u);
covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullPath.c_str());
@@ -575,7 +565,7 @@ int cmCTestCoverageHandler::ProcessHandler()
int untested = 0;
std::string line;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Actually performing coverage for: " << *i << std::endl,
+ "Actually performing coverage for: " << u << std::endl,
this->Quiet);
while (cmSystemTools::GetLineFromStream(ifs, line)) {
covLogXML.StartElement("Line");
@@ -591,13 +581,13 @@ int cmCTestCoverageHandler::ProcessHandler()
total_untested += untested;
covSumXML.StartElement("File");
covSumXML.Attribute("Name", fileName);
- covSumXML.Attribute("FullPath", *i);
+ covSumXML.Attribute("FullPath", u);
covSumXML.Attribute("Covered", "true");
covSumXML.Element("LOCTested", 0);
covSumXML.Element("LOCUnTested", untested);
covSumXML.Element("PercentCoverage", 0);
covSumXML.Element("CoverageMetric", 0);
- this->WriteXMLLabels(covSumXML, *i);
+ this->WriteXMLLabels(covSumXML, u);
covSumXML.EndElement(); // File
}
@@ -608,10 +598,8 @@ int cmCTestCoverageHandler::ProcessHandler()
cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error(s) while accumulating results:" << std::endl);
- std::vector<std::string>::iterator erIt;
- for (erIt = errorsWhileAccumulating.begin();
- erIt != errorsWhileAccumulating.end(); ++erIt) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " " << *erIt << std::endl);
+ for (std::string const& er : errorsWhileAccumulating) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, " " << er << std::endl);
}
}
@@ -668,17 +656,14 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
this->CustomCoverageExclude);
this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
this->ExtraCoverageGlobs);
- std::vector<std::string>::iterator it;
- for (it = this->CustomCoverageExclude.begin();
- it != this->CustomCoverageExclude.end(); ++it) {
+ for (std::string const& cce : this->CustomCoverageExclude) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage exclude: " << *it << std::endl,
+ " Add coverage exclude: " << cce << std::endl,
this->Quiet);
}
- for (it = this->ExtraCoverageGlobs.begin();
- it != this->ExtraCoverageGlobs.end(); ++it) {
+ for (std::string const& ecg : this->ExtraCoverageGlobs) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage glob: " << *it << std::endl,
+ " Add coverage glob: " << ecg << std::endl,
this->Quiet);
}
}
@@ -893,12 +878,12 @@ int cmCTestCoverageHandler::HandleBlanketJSCoverage(
// Blanket.js output. Check for the "node-jscoverage"
// string on the second line
std::string line;
- for (unsigned int fileEntry = 0; fileEntry < files.size(); fileEntry++) {
- cmsys::ifstream in(files[fileEntry].c_str());
+ for (std::string const& fileEntry : files) {
+ cmsys::ifstream in(fileEntry.c_str());
cmSystemTools::GetLineFromStream(in, line);
cmSystemTools::GetLineFromStream(in, line);
if (line.find("node-jscoverage") != std::string::npos) {
- blanketFiles.push_back(files[fileEntry]);
+ blanketFiles.push_back(fileEntry);
}
}
// Take all files with the node-jscoverage string and parse those
@@ -959,7 +944,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::vector<std::string> files;
this->FindGCovFiles(files);
- std::vector<std::string>::iterator it;
if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -994,15 +978,15 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
// These are binary files that you give as input to gcov so that it will
// give us text output we can analyze to summarize coverage.
//
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& f : files) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
// Call gcov to get coverage data for this *.gcda file:
//
- std::string fileDir = cmSystemTools::GetFilenamePath(*it);
+ std::string fileDir = cmSystemTools::GetFilenamePath(f);
std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " +
- "-o \"" + fileDir + "\" " + "\"" + *it + "\"";
+ "-o \"" + fileDir + "\" " + "\"" + f + "\"";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
command << std::endl, this->Quiet);
@@ -1020,7 +1004,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
*cont->OFS << " Errors: " << errors << std::endl;
if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << errors << std::endl);
cont->Error++;
@@ -1028,7 +1012,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
if (retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ << retVal << " while processing: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << cont->Error << std::endl);
}
@@ -1042,20 +1026,19 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->Quiet);
std::vector<std::string> lines;
- std::vector<std::string>::iterator line;
cmSystemTools::Split(output.c_str(), lines);
- for (line = lines.begin(); line != lines.end(); ++line) {
+ for (std::string const& line : lines) {
std::string sourceFile;
std::string gcovFile;
cmCTestOptionalLog(this->CTest, DEBUG,
- "Line: [" << *line << "]" << std::endl, this->Quiet);
+ "Line: [" << line << "]" << std::endl, this->Quiet);
- if (line->empty()) {
+ if (line.empty()) {
// Ignore empty line; probably style 2
- } else if (st1re1.find(line->c_str())) {
+ } else if (st1re1.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
@@ -1068,7 +1051,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
actualSourceFile = "";
sourceFile = st1re1.match(2);
- } else if (st1re2.find(line->c_str())) {
+ } else if (st1re2.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
@@ -1080,7 +1063,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
gcovFile = st1re2.match(1);
- } else if (st2re1.find(line->c_str())) {
+ } else if (st2re1.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1093,7 +1076,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
actualSourceFile = "";
sourceFile = st2re1.match(1);
- } else if (st2re2.find(line->c_str())) {
+ } else if (st2re2.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1103,7 +1086,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cont->Error++;
break;
}
- } else if (st2re3.find(line->c_str())) {
+ } else if (st2re3.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1115,7 +1098,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
gcovFile = st2re3.match(2);
- } else if (st2re4.find(line->c_str())) {
+ } else if (st2re4.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1130,7 +1113,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
"Warning: " << st2re4.match(1)
<< " had unexpected EOF" << std::endl,
this->Quiet);
- } else if (st2re5.find(line->c_str())) {
+ } else if (st2re5.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1144,7 +1127,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestOptionalLog(this->CTest, WARNING, "Warning: Cannot open file: "
<< st2re5.match(1) << std::endl,
this->Quiet);
- } else if (st2re6.find(line->c_str())) {
+ } else if (st2re6.find(line.c_str())) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
@@ -1162,10 +1145,10 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
} else {
// gcov 4.7 can have output lines saying "No executable lines" and
// "Removing 'filename.gcov'"... Don't log those as "errors."
- if (*line != "No executable lines" &&
- !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) {
+ if (line != "No executable lines" &&
+ !cmSystemTools::StringStartsWith(line.c_str(), "Removing ")) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: ["
- << *line << "]" << std::endl);
+ << line << "]" << std::endl);
cont->Error++;
// abort();
}
@@ -1330,7 +1313,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
"Error while finding LCov files.\n");
return 0;
}
- std::vector<std::string>::iterator it;
if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1357,10 +1339,10 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
// In intel compiler we have to call codecov only once in each executable
// directory. It collects all *.dyn files to generate .dpi file.
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& f : files) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
- std::string fileDir = cmSystemTools::GetFilenamePath(*it);
+ std::string fileDir = cmSystemTools::GetFilenamePath(f);
cmWorkingDirectory workdir(fileDir);
std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
@@ -1383,7 +1365,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
*cont->OFS << " Errors: " << errors << std::endl;
if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << errors << std::endl);
cont->Error++;
@@ -1391,7 +1373,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
}
if (retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ << retVal << " while processing: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << cont->Error << std::endl);
}
@@ -1405,15 +1387,14 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
this->Quiet);
std::vector<std::string> lines;
- std::vector<std::string>::iterator line;
cmSystemTools::Split(output.c_str(), lines);
- for (line = lines.begin(); line != lines.end(); ++line) {
+ for (std::string const& line : lines) {
std::string sourceFile;
std::string lcovFile;
- if (line->empty()) {
+ if (line.empty()) {
// Ignore empty line
}
// Look for LCOV files in binary directory
@@ -1436,9 +1417,8 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(),
gl.GetFiles().end());
- for (std::vector<std::string>::iterator a = lcovFiles.begin();
- a != lcovFiles.end(); ++a) {
- lcovFile = *a;
+ for (std::string const& file : lcovFiles) {
+ lcovFile = file;
cmsys::ifstream srcead(lcovFile.c_str());
if (!srcead) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -1460,10 +1440,9 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
sourceFile = srcname;
actualSourceFile = srcname;
- for (std::vector<std::string>::iterator t = lcovFiles.begin();
- t != lcovFiles.end(); ++t) {
+ for (std::string const& t : lcovFiles) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found LCOV File: " << *t << std::endl,
+ "Found LCOV File: " << t << std::endl,
this->Quiet);
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1560,10 +1539,9 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
- for (LabelMapType::const_iterator lmi = this->TargetDirs.begin();
- lmi != this->TargetDirs.end(); ++lmi) {
+ for (auto const& lm : this->TargetDirs) {
// Skip targets containing no interesting labels.
- if (!this->IntersectsFilter(lmi->second)) {
+ if (!this->IntersectsFilter(lm.second)) {
continue;
}
@@ -1571,12 +1549,12 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
// support directory.
cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT,
- " globbing for coverage in: " << lmi->first << std::endl, this->Quiet);
- std::string daGlob = lmi->first;
+ " globbing for coverage in: " << lm.first << std::endl, this->Quiet);
+ std::string daGlob = lm.first;
daGlob += "/*.da";
gl.FindFiles(daGlob);
files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
- daGlob = lmi->first;
+ daGlob = lm.first;
daGlob += "/*.gcda";
gl.FindFiles(daGlob);
files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
@@ -1639,14 +1617,13 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string tempDir = testingDir + "/CoverageInfo";
cmSystemTools::MakeDirectory(tempDir.c_str());
- std::vector<std::string>::iterator fileIt;
int file_count = 0;
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
- std::string fileName = this->FindFile(cont, *fileIt);
+ for (std::string const& file : files) {
+ std::string fileName = this->FindFile(cont, file);
if (fileName.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find source Python file corresponding to: "
- << *fileIt << std::endl);
+ << file << std::endl);
continue;
}
@@ -1658,11 +1635,11 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec =
&cont->TotalCoverage[actualSourceFile];
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in file: " << *fileIt << std::endl, this->Quiet);
- cmsys::ifstream ifile(fileIt->c_str());
+ " in file: " << file << std::endl, this->Quiet);
+ cmsys::ifstream ifile(file.c_str());
if (!ifile) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open file: " << *fileIt << std::endl);
+ "Cannot open file: " << file << std::endl);
} else {
long cnt = -1;
std::string nl;
@@ -2254,9 +2231,8 @@ void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
LabelMapType::const_iterator li = this->SourceLabels.find(source);
if (li != this->SourceLabels.end() && !li->second.empty()) {
xml.StartElement("Labels");
- for (LabelSet::const_iterator lsi = li->second.begin();
- lsi != li->second.end(); ++lsi) {
- xml.Element("Label", this->Labels[*lsi]);
+ for (auto const& ls : li->second) {
+ xml.Element("Label", this->Labels[ls]);
}
xml.EndElement(); // Labels
}
@@ -2266,9 +2242,8 @@ void cmCTestCoverageHandler::SetLabelFilter(
std::set<std::string> const& labels)
{
this->LabelFilter.clear();
- for (std::set<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- this->LabelFilter.insert(this->GetLabelId(*li));
+ for (std::string const& l : labels) {
+ this->LabelFilter.insert(this->GetLabelId(l));
}
}
@@ -2308,29 +2283,24 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
{
std::set<std::string> extraMatches;
- for (std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
- i != this->ExtraCoverageGlobs.end(); ++i) {
+ for (std::string const& ecg : this->ExtraCoverageGlobs) {
cmsys::Glob gl;
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
- std::string glob = cont->SourceDir + "/" + *i;
+ std::string glob = cont->SourceDir + "/" + ecg;
gl.FindFiles(glob);
std::vector<std::string> files = gl.GetFiles();
- for (std::vector<std::string>::iterator f = files.begin();
- f != files.end(); ++f) {
- if (this->ShouldIDoCoverage(f->c_str(), cont->SourceDir.c_str(),
+ for (std::string const& f : files) {
+ if (this->ShouldIDoCoverage(f.c_str(), cont->SourceDir.c_str(),
cont->BinaryDir.c_str())) {
- extraMatches.insert(this->CTest->GetShortPathToFile(f->c_str()));
+ extraMatches.insert(this->CTest->GetShortPathToFile(f.c_str()));
}
}
}
if (!extraMatches.empty()) {
- for (cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
- cont->TotalCoverage.begin();
- i != cont->TotalCoverage.end(); ++i) {
- std::string shortPath =
- this->CTest->GetShortPathToFile(i->first.c_str());
+ for (auto const& i : cont->TotalCoverage) {
+ std::string shortPath = this->CTest->GetShortPathToFile(i.first.c_str());
extraMatches.erase(shortPath);
}
}
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index b175d449b3..022afd2fbc 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -61,12 +61,11 @@ size_t curlDebugCallback(CURL* /*unused*/, curl_infotype /*unused*/,
void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
{
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
+ for (std::string const& arg : args) {
+ if (arg == "CURLOPT_SSL_VERIFYPEER_OFF") {
this->VerifyPeerOff = true;
}
- if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
+ if (arg == "CURLOPT_SSL_VERIFYHOST_OFF") {
this->VerifyHostOff = true;
}
}
@@ -146,12 +145,11 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
struct curl_slist* headers =
::curl_slist_append(nullptr, "Content-Type: text/xml");
// Add any additional headers that the user specified.
- for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
+ for (std::string const& h : this->HttpHeaders) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
@@ -213,13 +211,11 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
// Add headers if any were specified.
struct curl_slist* headers = nullptr;
if (!this->HttpHeaders.empty()) {
- for (std::vector<std::string>::const_iterator h =
- this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
+ for (std::string const& h : this->HttpHeaders) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
}
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index ed8d9325fe..fa5388a70d 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -163,9 +163,8 @@ bool cmCTestGIT::UpdateByFetchAndReset()
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- git_fetch.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ git_fetch.push_back(arg.c_str());
}
// Sentinel argument.
@@ -215,9 +214,8 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
std::vector<std::string> git_custom_command;
cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
std::vector<char const*> git_custom;
- for (std::vector<std::string>::const_iterator i = git_custom_command.begin();
- i != git_custom_command.end(); ++i) {
- git_custom.push_back(i->c_str());
+ for (std::string const& i : git_custom_command) {
+ git_custom.push_back(i.c_str());
}
git_custom.push_back(nullptr);
@@ -655,9 +653,8 @@ bool cmCTestGIT::LoadModifications()
OutputLogger err(this->Log, "di-err> ");
this->RunChild(git_diff_index, &out, &err, nullptr, cmProcessOutput::UTF8);
- for (std::vector<Change>::const_iterator ci = out.Changes.begin();
- ci != out.Changes.end(); ++ci) {
- this->DoModification(PathModified, ci->Path);
+ for (Change const& c : out.Changes) {
+ this->DoModification(PathModified, c.Path);
}
return true;
}
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 53a4018057..ce8f709981 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -57,10 +57,8 @@ void cmCTestGenericHandler::Initialize()
this->AppendXML = false;
this->TestLoad = 0;
this->Options.clear();
- t_StringToString::iterator it;
- for (it = this->PersistentOptions.begin();
- it != this->PersistentOptions.end(); ++it) {
- this->Options[it->first] = it->second;
+ for (auto const& po : this->PersistentOptions) {
+ this->Options[po.first] = po.second;
}
}
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 25294b5ae0..d2714d90b4 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -48,15 +48,14 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
/* clang-format on */
// Update information about revisions of the changed files.
- for (std::vector<Change>::const_iterator ci = changes.begin();
- ci != changes.end(); ++ci) {
- if (const char* local = this->LocalPath(ci->Path)) {
+ for (Change const& c : changes) {
+ if (const char* local = this->LocalPath(c.Path)) {
std::string dir = cmSystemTools::GetFilenamePath(local);
std::string name = cmSystemTools::GetFilenameName(local);
File& file = this->Dirs[dir][name];
file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
file.Rev = &rev;
- this->Log << " " << ci->Action << " " << local << " "
+ this->Log << " " << c.Action << " " << local << " "
<< "\n";
}
}
@@ -83,9 +82,9 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
const char* slash = path.empty() ? "" : "/";
xml.StartElement("Directory");
xml.Element("Name", path);
- for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
- std::string full = path + slash + fi->first;
- this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
+ for (auto const& f : dir) {
+ std::string const full = path + slash + f.first;
+ this->WriteXMLEntry(xml, path, f.first, full, f.second);
}
xml.EndElement(); // Directory
}
@@ -114,10 +113,8 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
this->WriteXMLGlobal(xml);
- for (std::map<std::string, Directory>::const_iterator di =
- this->Dirs.begin();
- di != this->Dirs.end(); ++di) {
- this->WriteXMLDirectory(xml, di->first, di->second);
+ for (auto const& d : this->Dirs) {
+ this->WriteXMLDirectory(xml, d.first, d.second);
}
return result;
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 7bf5b67bab..78353b3a82 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -145,9 +145,8 @@ bool cmCTestHG::UpdateImpl()
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- hg_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ hg_update.push_back(arg.c_str());
}
// Sentinel argument.
@@ -217,25 +216,25 @@ private:
this->Rev.Log.assign(&this->CData[0], this->CData.size());
} else if (!this->CData.empty() && name == "files") {
std::vector<std::string> paths = this->SplitCData();
- for (unsigned int i = 0; i < paths.size(); ++i) {
+ for (std::string const& path : paths) {
// Updated by default, will be modified using file_adds and
// file_dels.
this->CurChange = Change('U');
- this->CurChange.Path = paths[i];
+ this->CurChange.Path = path;
this->Changes.push_back(this->CurChange);
}
} else if (!this->CData.empty() && name == "file_adds") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for (unsigned int i = 0; i < this->Changes.size(); ++i) {
- if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
- this->Changes[i].Action = 'A';
+ for (Change& change : this->Changes) {
+ if (added_paths.find(change.Path) != std::string::npos) {
+ change.Action = 'A';
}
}
} else if (!this->CData.empty() && name == "file_dels") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for (unsigned int i = 0; i < this->Changes.size(); ++i) {
- if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
- this->Changes[i].Action = 'D';
+ for (Change& change : this->Changes) {
+ if (added_paths.find(change.Path) != std::string::npos) {
+ change.Action = 'D';
}
}
}
@@ -246,9 +245,9 @@ private:
{
std::vector<std::string> output;
std::string currPath;
- for (unsigned int i = 0; i < this->CData.size(); ++i) {
- if (this->CData[i] != ' ') {
- currPath += this->CData[i];
+ for (char i : this->CData) {
+ if (i != ' ') {
+ currPath += i;
} else {
output.push_back(currPath);
currPath = "";
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 9266d1fa8c..5a7baf545f 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -97,12 +97,11 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
// bad one so that CAPTURE_CMAKE_ERROR can override setting the
// global error state
bool foundBadArgument = false;
- for (unsigned int i = 0; i < args.size(); ++i) {
+ for (std::string const& arg : args) {
// Check this argument.
- if (!this->CheckArgumentKeyword(args[i]) &&
- !this->CheckArgumentValue(args[i])) {
+ if (!this->CheckArgumentKeyword(arg) && !this->CheckArgumentValue(arg)) {
std::ostringstream e;
- e << "called with unknown argument \"" << args[i] << "\".";
+ e << "called with unknown argument \"" << arg << "\".";
this->SetError(e.str());
foundBadArgument = true;
}
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 041cc92e18..453ae99d27 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -169,9 +169,8 @@ void cmCTestLaunch::ComputeFileNames()
cmCryptoHash md5(cmCryptoHash::AlgoMD5);
md5.Initialize();
md5.Append(this->CWD);
- for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai) {
- md5.Append(*ai);
+ for (std::string const& realArg : this->RealArgs) {
+ md5.Append(realArg);
}
this->LogHash = md5.FinalizeHex();
@@ -422,9 +421,8 @@ void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml)
if (!this->CWD.empty()) {
xml.Element("WorkingDirectory", this->CWD);
}
- for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai) {
- xml.Element("Argument", *ai);
+ for (std::string const& realArg : this->RealArgs) {
+ xml.Element("Argument", realArg);
}
xml.EndElement(); // Command
}
@@ -487,9 +485,8 @@ void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml)
if (!this->Labels.empty()) {
xml.Comment("Interested parties");
xml.StartElement("Labels");
- for (std::set<std::string>::const_iterator li = this->Labels.begin();
- li != this->Labels.end(); ++li) {
- xml.Element("Label", *li);
+ for (std::string const& label : this->Labels) {
+ xml.Element("Label", label);
}
xml.EndElement(); // Labels
}
@@ -597,9 +594,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
bool cmCTestLaunch::Match(std::string const& line,
std::vector<cmsys::RegularExpression>& regexps)
{
- for (std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
- ri != regexps.end(); ++ri) {
- if (ri->find(line.c_str())) {
+ for (cmsys::RegularExpression& r : regexps) {
+ if (r.find(line.c_str())) {
return true;
}
}
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 3f11543a95..1058806939 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -157,15 +157,13 @@ int cmCTestMemCheckHandler::PostProcessHandler()
void cmCTestMemCheckHandler::GenerateTestCommand(
std::vector<std::string>& args, int test)
{
- std::vector<std::string>::size_type pp;
std::string index;
std::ostringstream stream;
std::string memcheckcommand =
cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
stream << test;
index = stream.str();
- for (pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp++) {
- std::string arg = this->MemoryTesterDynamicOptions[pp];
+ for (std::string arg : this->MemoryTesterDynamicOptions) {
std::string::size_type pos = arg.find("??");
if (pos != std::string::npos) {
arg.replace(pos, 2, index);
@@ -180,18 +178,18 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
// via environment varaibles.
std::string memTesterEnvironmentVariable =
this->MemoryTesterEnvironmentVariable;
- for (pp = 0; pp < this->MemoryTesterOptions.size(); pp++) {
+ for (std::string const& arg : this->MemoryTesterOptions) {
if (!memTesterEnvironmentVariable.empty()) {
// If we are using env to pass options, append all the options to
// this string with space separation.
- memTesterEnvironmentVariable += " " + this->MemoryTesterOptions[pp];
+ memTesterEnvironmentVariable += " " + arg;
}
// for regular options just add them to args and memcheckcommand
// which is just used for display
else {
- args.push_back(this->MemoryTesterOptions[pp]);
+ args.push_back(arg);
memcheckcommand += " \"";
- memcheckcommand += this->MemoryTesterOptions[pp];
+ memcheckcommand += arg;
memcheckcommand += "\"";
}
}
@@ -326,9 +324,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
- std::string testPath = result->Path + "/" + result->Name;
+ for (cmCTestTestResult const& result : this->TestResults) {
+ std::string testPath = result.Path + "/" + result.Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
xml.EndElement(); // TestList
@@ -336,12 +333,12 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
"-- Processing memory checking output:\n", this->Quiet);
size_t total = this->TestResults.size();
for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
+ cmCTestTestResult const& result = this->TestResults[cc];
std::string memcheckstr;
std::vector<int> memcheckresults(this->ResultStrings.size(), 0);
- bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
- memcheckresults);
- if (res && result->Status == cmCTestMemCheckHandler::COMPLETED) {
+ bool res =
+ this->ProcessMemCheckOutput(result.Output, memcheckstr, memcheckresults);
+ if (res && result.Status == cmCTestMemCheckHandler::COMPLETED) {
continue;
}
this->CleanTestOutput(
@@ -364,11 +361,11 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.EndElement(); // Results
if (memoryErrors > 0) {
const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
- std::string outname = result->Name + " ";
+ std::string outname = result.Name + " ";
outname.resize(maxTestNameWidth + 4, '.');
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, cc + 1
<< "/" << total << " MemCheck: #"
- << result->TestCount << ": " << outname
+ << result.TestCount << ": " << outname
<< " Defects: " << memoryErrors << std::endl,
this->Quiet);
}
@@ -729,12 +726,11 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
cmSystemTools::Split(str.c_str(), lines);
std::ostringstream ostr;
log = "";
- for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
- ++i) {
+ for (std::string const& l : lines) {
std::string resultFound;
- if (leakWarning.find(*i)) {
+ if (leakWarning.find(l)) {
resultFound = leakWarning.match(1) + " leak";
- } else if (sanitizerWarning.find(*i)) {
+ } else if (sanitizerWarning.find(l)) {
resultFound = sanitizerWarning.match(1);
}
if (!resultFound.empty()) {
@@ -747,7 +743,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
defects++;
ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
}
- ostr << *i << std::endl;
+ ostr << l << std::endl;
}
log = ostr.str();
this->DefectCount += defects;
@@ -765,10 +761,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
int defects = 0;
- for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
- ++i) {
+ for (std::string const& l : lines) {
std::vector<int>::size_type failure = this->ResultStrings.size();
- if (pfW.find(*i)) {
+ if (pfW.find(l)) {
std::vector<int>::size_type cc;
for (cc = 0; cc < this->ResultStrings.size(); cc++) {
if (pfW.match(1) == this->ResultStrings[cc]) {
@@ -788,7 +783,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
results[failure]++;
defects++;
}
- ostr << *i << std::endl;
+ ostr << l << std::endl;
}
log = ostr.str();
@@ -908,11 +903,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
// Now put all all the non valgrind output into the test output
// This should be last in case it gets truncated by the output
// limiting code
- for (std::vector<std::string::size_type>::iterator i =
- nonValGrindOutput.begin();
- i != nonValGrindOutput.end(); ++i) {
- totalOutputSize += lines[*i].size();
- ostr << lines[*i] << std::endl;
+ for (std::string::size_type i : nonValGrindOutput) {
+ totalOutputSize += lines[i].size();
+ ostr << lines[i] << std::endl;
if (!unlimitedOutput &&
totalOutputSize >
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)) {
@@ -963,8 +956,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
}
}
int defects = 0;
- for (cc = 0; cc < parser.Errors.size(); ++cc) {
- results[parser.Errors[cc]]++;
+ for (int err : parser.Errors) {
+ results[err]++;
defects++;
}
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
@@ -991,9 +984,8 @@ void cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res, int test)
} else {
std::vector<std::string> files;
this->TestOutputFileNames(test, files);
- for (std::vector<std::string>::iterator i = files.begin();
- i != files.end(); ++i) {
- this->AppendMemTesterOutput(res, *i);
+ for (std::string const& f : files) {
+ this->AppendMemTesterOutput(res, f);
}
}
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 2c16a0d1ee..c85337336f 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -64,10 +64,9 @@ void cmCTestMultiProcessHandler::SetTests(TestMap& tests,
this->Properties = properties;
this->Total = this->Tests.size();
// set test run map to false for all
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- this->TestRunningMap[i->first] = false;
- this->TestFinishMap[i->first] = false;
+ for (auto const& t : this->Tests) {
+ this->TestRunningMap[t.first] = false;
+ this->TestFinishMap[t.first] = false;
}
if (!this->CTest->GetShowOnly()) {
this->ReadCostData();
@@ -131,11 +130,10 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
// Find any failed dependencies for this test. We assume the more common
// scenario has no failed tests, so make it the outer loop.
- for (std::vector<std::string>::const_iterator it = this->Failed->begin();
- it != this->Failed->end(); ++it) {
- if (this->Properties[test]->RequireSuccessDepends.find(*it) !=
+ for (std::string const& f : *this->Failed) {
+ if (this->Properties[test]->RequireSuccessDepends.find(f) !=
this->Properties[test]->RequireSuccessDepends.end()) {
- testRun->AddFailedDependency(*it);
+ testRun->AddFailedDependency(f);
}
}
@@ -152,9 +150,8 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
return;
} else {
- for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
- ++j) {
- j->second.erase(test);
+ for (auto& j : this->Tests) {
+ j.second.erase(test);
}
this->UnlockResources(test);
@@ -183,10 +180,8 @@ void cmCTestMultiProcessHandler::LockResources(int index)
void cmCTestMultiProcessHandler::UnlockResources(int index)
{
- for (std::set<std::string>::iterator i =
- this->Properties[index]->LockedResources.begin();
- i != this->Properties[index]->LockedResources.end(); ++i) {
- this->LockedResources.erase(*i);
+ for (std::string const& i : this->Properties[index]->LockedResources) {
+ this->LockedResources.erase(i);
}
if (this->Properties[index]->RunSerial) {
this->SerialTestRunning = false;
@@ -219,10 +214,8 @@ std::string cmCTestMultiProcessHandler::GetName(int test)
bool cmCTestMultiProcessHandler::StartTest(int test)
{
// Check for locked resources
- for (std::set<std::string>::iterator i =
- this->Properties[test]->LockedResources.begin();
- i != this->Properties[test]->LockedResources.end(); ++i) {
- if (this->LockedResources.find(*i) != this->LockedResources.end()) {
+ for (std::string const& i : this->Properties[test]->LockedResources) {
+ if (this->LockedResources.find(i) != this->LockedResources.end()) {
return false;
}
}
@@ -292,22 +285,22 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
TestList copy = this->SortedTests;
- for (TestList::iterator test = copy.begin(); test != copy.end(); ++test) {
+ for (auto const& test : copy) {
// Take a nap if we're currently performing a RUN_SERIAL test.
if (this->SerialTestRunning) {
break;
}
// We can only start a RUN_SERIAL test if no other tests are also running.
- if (this->Properties[*test]->RunSerial && this->RunningCount > 0) {
+ if (this->Properties[test]->RunSerial && this->RunningCount > 0) {
continue;
}
- size_t processors = GetProcessorsUsed(*test);
+ size_t processors = GetProcessorsUsed(test);
bool testLoadOk = true;
if (this->TestLoad > 0) {
if (processors <= spareLoad) {
cmCTestLog(this->CTest, DEBUG, "OK to run "
- << GetName(*test) << ", it requires " << processors
+ << GetName(test) << ", it requires " << processors
<< " procs & system load is: " << systemLoad
<< std::endl);
allTestsFailedTestLoadCheck = false;
@@ -318,10 +311,10 @@ void cmCTestMultiProcessHandler::StartNextTests()
if (processors <= minProcessorsRequired) {
minProcessorsRequired = processors;
- testWithMinProcessors = GetName(*test);
+ testWithMinProcessors = GetName(test);
}
- if (testLoadOk && processors <= numToStart && this->StartTest(*test)) {
+ if (testLoadOk && processors <= numToStart && this->StartTest(test)) {
if (this->StopTimePassed) {
return;
}
@@ -368,18 +361,13 @@ bool cmCTestMultiProcessHandler::CheckOutput()
}
std::vector<cmCTestRunTest*> finished;
std::string out, err;
- for (std::set<cmCTestRunTest*>::const_iterator i =
- this->RunningTests.begin();
- i != this->RunningTests.end(); ++i) {
- cmCTestRunTest* p = *i;
+ for (cmCTestRunTest* p : this->RunningTests) {
if (!p->CheckOutput()) {
finished.push_back(p);
}
}
- for (std::vector<cmCTestRunTest*>::iterator i = finished.begin();
- i != finished.end(); ++i) {
+ for (cmCTestRunTest* p : finished) {
this->Completed++;
- cmCTestRunTest* p = *i;
int test = p->GetIndex();
bool testResult = p->EndTest(this->Completed, this->Total, true);
@@ -392,9 +380,8 @@ bool cmCTestMultiProcessHandler::CheckOutput()
} else {
this->Failed->push_back(p->GetTestProperties()->Name);
}
- for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
- ++j) {
- j->second.erase(test);
+ for (auto& t : this->Tests) {
+ t.second.erase(test);
}
this->TestFinishMap[test] = true;
this->TestRunningMap[test] = false;
@@ -451,16 +438,15 @@ void cmCTestMultiProcessHandler::UpdateCostData()
}
// Add all tests not previously listed in the file
- for (PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i) {
- fout << i->second->Name << " " << i->second->PreviousRuns << " "
- << i->second->Cost << "\n";
+ for (auto const& i : temp) {
+ fout << i.second->Name << " " << i.second->PreviousRuns << " "
+ << i.second->Cost << "\n";
}
// Write list of failed tests
fout << "---\n";
- for (std::vector<std::string>::iterator i = this->Failed->begin();
- i != this->Failed->end(); ++i) {
- fout << *i << "\n";
+ for (std::string const& f : *this->Failed) {
+ fout << f << "\n";
}
fout.close();
cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str());
@@ -517,10 +503,9 @@ int cmCTestMultiProcessHandler::SearchByName(std::string const& name)
{
int index = -1;
- for (PropertiesMap::iterator i = this->Properties.begin();
- i != this->Properties.end(); ++i) {
- if (i->second->Name == name) {
- index = i->first;
+ for (auto const& p : this->Properties) {
+ if (p.second->Name == name) {
+ index = p.first;
}
}
return index;
@@ -545,16 +530,15 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// In parallel test runs add previously failed tests to the front
// of the cost list and queue other tests for further sorting
- for (TestMap::const_iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
+ for (auto const& t : this->Tests) {
if (std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
- this->Properties[i->first]->Name) !=
+ this->Properties[t.first]->Name) !=
this->LastTestsFailed.end()) {
// If the test failed last time, it should be run first.
- this->SortedTests.push_back(i->first);
- alreadySortedTests.insert(i->first);
+ this->SortedTests.push_back(t.first);
+ alreadySortedTests.insert(t.first);
} else {
- topLevel.insert(i->first);
+ topLevel.insert(t.first);
}
}
@@ -566,15 +550,13 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
priorityStack.push_back(TestSet());
TestSet& currentSet = priorityStack.back();
- for (TestSet::const_iterator i = previousSet.begin();
- i != previousSet.end(); ++i) {
- TestSet const& dependencies = this->Tests[*i];
+ for (auto const& i : previousSet) {
+ TestSet const& dependencies = this->Tests[i];
currentSet.insert(dependencies.begin(), dependencies.end());
}
- for (TestSet::const_iterator i = currentSet.begin(); i != currentSet.end();
- ++i) {
- previousSet.erase(*i);
+ for (auto const& i : currentSet) {
+ previousSet.erase(i);
}
}
@@ -594,11 +576,10 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp);
- for (TestList::const_iterator j = sortedCopy.begin();
- j != sortedCopy.end(); ++j) {
- if (alreadySortedTests.find(*j) == alreadySortedTests.end()) {
- this->SortedTests.push_back(*j);
- alreadySortedTests.insert(*j);
+ for (auto const& j : sortedCopy) {
+ if (alreadySortedTests.find(j) == alreadySortedTests.end()) {
+ this->SortedTests.push_back(j);
+ alreadySortedTests.insert(j);
}
}
}
@@ -608,10 +589,9 @@ void cmCTestMultiProcessHandler::GetAllTestDependencies(int test,
TestList& dependencies)
{
TestSet const& dependencySet = this->Tests[test];
- for (TestSet::const_iterator i = dependencySet.begin();
- i != dependencySet.end(); ++i) {
- GetAllTestDependencies(*i, dependencies);
- dependencies.push_back(*i);
+ for (int i : dependencySet) {
+ GetAllTestDependencies(i, dependencies);
+ dependencies.push_back(i);
}
}
@@ -619,9 +599,8 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
{
TestList presortedList;
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- presortedList.push_back(i->first);
+ for (auto const& i : this->Tests) {
+ presortedList.push_back(i.first);
}
TestComparator comp(this);
@@ -629,10 +608,7 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
TestSet alreadySortedTests;
- for (TestList::const_iterator i = presortedList.begin();
- i != presortedList.end(); ++i) {
- int test = *i;
-
+ for (int test : presortedList) {
if (alreadySortedTests.find(test) != alreadySortedTests.end()) {
continue;
}
@@ -640,10 +616,7 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
TestList dependencies;
GetAllTestDependencies(test, dependencies);
- for (TestList::const_iterator j = dependencies.begin();
- j != dependencies.end(); ++j) {
- int testDependency = *j;
-
+ for (int testDependency : dependencies) {
if (alreadySortedTests.find(testDependency) ==
alreadySortedTests.end()) {
alreadySortedTests.insert(testDependency);
@@ -679,10 +652,9 @@ void cmCTestMultiProcessHandler::PrintTestList()
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
int count = 0;
- for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it) {
+ for (auto& it : this->Properties) {
count++;
- cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+ cmCTestTestHandler::cmCTestTestProperties& p = *it.second;
cmWorkingDirectory workdir(p.Directory);
@@ -696,9 +668,8 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:",
this->Quiet);
}
- for (std::vector<std::string>::iterator label = p.Labels.begin();
- label != p.Labels.end(); ++label) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label,
+ for (std::string const& label : p.Labels) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << label,
this->Quiet);
}
if (!p.Labels.empty()) // print the labels
@@ -737,9 +708,8 @@ void cmCTestMultiProcessHandler::PrintTestList()
void cmCTestMultiProcessHandler::PrintLabels()
{
std::set<std::string> allLabels;
- for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it) {
- cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+ for (auto& it : this->Properties) {
+ cmCTestTestHandler::cmCTestTestProperties& p = *it.second;
allLabels.insert(p.Labels.begin(), p.Labels.end());
}
@@ -750,10 +720,9 @@ void cmCTestMultiProcessHandler::PrintLabels()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"No Labels Exist" << std::endl, this->Quiet);
}
- for (std::set<std::string>::iterator label = allLabels.begin();
- label != allLabels.end(); ++label) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " " << *label << std::endl, this->Quiet);
+ for (std::string const& label : allLabels) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " " << label << std::endl,
+ this->Quiet);
}
}
@@ -794,10 +763,9 @@ void cmCTestMultiProcessHandler::RemoveTest(int index)
int cmCTestMultiProcessHandler::FindMaxIndex()
{
int max = 0;
- cmCTestMultiProcessHandler::TestMap::iterator i = this->Tests.begin();
- for (; i != this->Tests.end(); ++i) {
- if (i->first > max) {
- max = i->first;
+ for (auto const& i : this->Tests) {
+ if (i.first > max) {
+ max = i.first;
}
}
return max;
@@ -809,10 +777,9 @@ bool cmCTestMultiProcessHandler::CheckCycles()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Checking test dependency graph..." << std::endl,
this->Quiet);
- for (TestMap::iterator it = this->Tests.begin(); it != this->Tests.end();
- ++it) {
+ for (auto const& it : this->Tests) {
// DFS from each element to itself
- int root = it->first;
+ int root = it.first;
std::set<int> visited;
std::stack<int> s;
s.push(root);
@@ -820,9 +787,8 @@ bool cmCTestMultiProcessHandler::CheckCycles()
int test = s.top();
s.pop();
if (visited.insert(test).second) {
- for (TestSet::iterator d = this->Tests[test].begin();
- d != this->Tests[test].end(); ++d) {
- if (*d == root) {
+ for (auto const& d : this->Tests[test]) {
+ if (d == root) {
// cycle exists
cmCTestLog(
this->CTest, ERROR_MESSAGE,
@@ -832,7 +798,7 @@ bool cmCTestMultiProcessHandler::CheckCycles()
<< "\".\nPlease fix the cycle and run ctest again.\n");
return false;
}
- s.push(*d);
+ s.push(d);
}
}
}
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index ab057ad937..1206b9af93 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -332,9 +332,8 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
}
CommandOptions.clear();
- for (std::vector<std::string>::iterator i = P4Options.begin();
- i != P4Options.end(); ++i) {
- CommandOptions.push_back(i->c_str());
+ for (std::string const& o : P4Options) {
+ CommandOptions.push_back(o.c_str());
}
}
@@ -465,9 +464,8 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
cmSystemTools::ExpandListArgument(custom, p4_custom_command, true);
std::vector<char const*> p4_custom;
- for (std::vector<std::string>::const_iterator i = p4_custom_command.begin();
- i != p4_custom_command.end(); ++i) {
- p4_custom.push_back(i->c_str());
+ for (std::string const& i : p4_custom_command) {
+ p4_custom.push_back(i.c_str());
}
p4_custom.push_back(nullptr);
@@ -502,9 +500,8 @@ bool cmCTestP4::UpdateImpl()
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
}
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- p4_sync.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ p4_sync.push_back(arg.c_str());
}
std::string source = this->SourceDirectory + "/...";
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
index b21be872f7..ed14d06887 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
@@ -14,9 +14,8 @@ bool cmCTestReadCustomFilesCommand::InitialPass(
return false;
}
- std::vector<std::string>::const_iterator dit;
- for (dit = args.begin(); dit != args.end(); ++dit) {
- this->CTest->ReadCustomConfigurationFileTree(dit->c_str(), this->Makefile);
+ for (std::string const& arg : args) {
+ this->CTest->ReadCustomConfigurationFileTree(arg.c_str(), this->Makefile);
}
return true;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index ddc309cdb3..a71e2ec21c 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -64,12 +64,8 @@ bool cmCTestRunTest::CheckOutput()
// Check for TIMEOUT_AFTER_MATCH property.
if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
- std::vector<std::pair<cmsys::RegularExpression, std::string>>::iterator
- regIt;
- for (regIt = this->TestProperties->TimeoutRegularExpressions.begin();
- regIt != this->TestProperties->TimeoutRegularExpressions.end();
- ++regIt) {
- if (regIt->first.find(this->ProcessOutput.c_str())) {
+ for (auto& reg : this->TestProperties->TimeoutRegularExpressions) {
+ if (reg.first.find(this->ProcessOutput.c_str())) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
<< ": "
<< "Test timeout changed to "
@@ -163,18 +159,14 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
int res =
started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
int retVal = this->TestProcess->GetExitValue();
- std::vector<std::pair<cmsys::RegularExpression, std::string>>::iterator
- passIt;
bool forceFail = false;
bool skipped = false;
bool outputTestErrorsToConsole = false;
if (!this->TestProperties->RequiredRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
bool found = false;
- for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++passIt) {
- if (passIt->first.find(this->ProcessOutput.c_str())) {
+ for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
+ if (pass.first.find(this->ProcessOutput.c_str())) {
found = true;
reason = "Required regular expression found.";
break;
@@ -185,23 +177,19 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
forceFail = true;
}
reason += "Regex=[";
- for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++passIt) {
- reason += passIt->second;
+ for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
+ reason += pass.second;
reason += "\n";
}
reason += "]";
}
if (!this->TestProperties->ErrorRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
- for (passIt = this->TestProperties->ErrorRegularExpressions.begin();
- passIt != this->TestProperties->ErrorRegularExpressions.end();
- ++passIt) {
- if (passIt->first.find(this->ProcessOutput.c_str())) {
+ for (auto& pass : this->TestProperties->ErrorRegularExpressions) {
+ if (pass.first.find(this->ProcessOutput.c_str())) {
reason = "Error regular expression found in output.";
reason += " Regex=[";
- reason += passIt->second;
+ reason += pass.second;
reason += "]";
forceFail = true;
break;
@@ -457,10 +445,8 @@ bool cmCTestRunTest::StartTest(size_t total)
if (!this->FailedDependencies.empty()) {
this->TestProcess = new cmProcess;
std::string msg = "Failed test dependencies:";
- for (std::set<std::string>::const_iterator it =
- this->FailedDependencies.begin();
- it != this->FailedDependencies.end(); ++it) {
- msg += " " + *it;
+ for (std::string const& failedDep : this->FailedDependencies) {
+ msg += " " + failedDep;
}
*this->TestHandler->LogFile << msg << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, msg << std::endl);
@@ -492,11 +478,7 @@ bool cmCTestRunTest::StartTest(size_t total)
}
// Check if all required files exist
- for (std::vector<std::string>::iterator i =
- this->TestProperties->RequiredFiles.begin();
- i != this->TestProperties->RequiredFiles.end(); ++i) {
- std::string file = *i;
-
+ for (std::string const& file : this->TestProperties->RequiredFiles) {
if (!cmSystemTools::FileExists(file.c_str())) {
// Required file was not found
this->TestProcess = new cmProcess;
@@ -560,10 +542,9 @@ void cmCTestRunTest::ComputeArguments()
// Prepends memcheck args to our command string
this->TestHandler->GenerateTestCommand(this->Arguments, this->Index);
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
+ for (std::string const& arg : this->Arguments) {
testCommand += " \"";
- testCommand += *i;
+ testCommand += arg;
testCommand += "\"";
}
@@ -587,10 +568,8 @@ void cmCTestRunTest::ComputeArguments()
<< ": "
<< "Environment variables: " << std::endl);
}
- for (std::vector<std::string>::const_iterator e =
- this->TestProperties->Environment.begin();
- e != this->TestProperties->Environment.end(); ++e) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << *e
+ for (std::string const& env : this->TestProperties->Environment) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << env
<< std::endl);
}
}
@@ -764,9 +743,8 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
<< std::endl;
*this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
- *this->TestHandler->LogFile << " \"" << *i << "\"";
+ for (std::string const& arg : this->Arguments) {
+ *this->TestHandler->LogFile << " \"" << arg << "\"";
}
*this->TestHandler->LogFile
<< std::endl
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 36582a2548..5936d0e8e0 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -103,10 +103,7 @@ bool cmCTestSVN::NoteOldRevision()
return false;
}
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
svninfo.OldRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' before update: " << svninfo.OldRevision << "\n";
@@ -127,10 +124,7 @@ bool cmCTestSVN::NoteNewRevision()
return false;
}
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
svninfo.NewRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' after update: " << svninfo.NewRevision << "\n";
@@ -257,9 +251,8 @@ bool cmCTestSVN::UpdateImpl()
std::vector<char const*> svn_update;
svn_update.push_back("update");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- svn_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ svn_update.push_back(arg.c_str());
}
UpdateParser out(this, "up-out> ");
@@ -285,9 +278,8 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
std::vector<std::string> parsedUserOptions =
cmSystemTools::ParseArguments(userOptions.c_str());
- for (std::vector<std::string>::iterator i = parsedUserOptions.begin();
- i != parsedUserOptions.end(); ++i) {
- args.push_back(i->c_str());
+ for (std::string const& opt : parsedUserOptions) {
+ args.push_back(opt.c_str());
}
args.push_back(nullptr);
@@ -380,10 +372,7 @@ bool cmCTestSVN::LoadRevisions()
{
bool result = true;
// Get revisions for all the external repositories
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
result = this->LoadRevisions(svninfo) && result;
}
return result;
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 6fd24a5181..7d1c24f157 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -245,10 +245,9 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
std::ostringstream message;
message << "Error running command: [";
message << result << "] ";
- for (std::vector<const char*>::iterator i = argv.begin(); i != argv.end();
- ++i) {
- if (*i) {
- message << *i << " ";
+ for (const char* arg : argv) {
+ if (arg) {
+ message << arg << " ";
}
}
cmCTestLog(this->CTest, ERROR_MESSAGE, message.str() << argv[0]
@@ -377,9 +376,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
// Add definitions of variables passed in on the command line:
const std::map<std::string, std::string>& defs =
this->CTest->GetDefinitions();
- for (std::map<std::string, std::string>::const_iterator it = defs.begin();
- it != defs.end(); ++it) {
- this->Makefile->AddDefinition(it->first, it->second.c_str());
+ for (auto const& d : defs) {
+ this->Makefile->AddDefinition(d.first, d.second.c_str());
}
// finally read in the script
@@ -654,10 +652,9 @@ int cmCTestScriptHandler::PerformExtraUpdates()
// do an initial cvs update as required
command = this->UpdateCmd;
- std::vector<std::string>::iterator it;
- for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++it) {
+ for (std::string const& eu : this->ExtraUpdates) {
std::vector<std::string> cvsArgs;
- cmSystemTools::ExpandListArgument(*it, cvsArgs);
+ cmSystemTools::ExpandListArgument(eu, cvsArgs);
if (cvsArgs.size() == 2) {
std::string fullCommand = command;
fullCommand += " update ";
@@ -670,7 +667,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
if (!res || retVal != 0) {
- cmSystemTools::Error("Unable to perform extra updates:\n", it->c_str(),
+ cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(),
"\nWith output:\n", output.c_str());
return 0;
}
@@ -803,8 +800,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
std::vector<std::string> ctestCommands;
cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands);
// for each variable/argument do a putenv
- for (unsigned i = 0; i < ctestCommands.size(); ++i) {
- command = ctestCommands[i];
+ for (std::string const& ctestCommand : ctestCommands) {
+ command = ctestCommand;
output = "";
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index b7d0d1fbd6..18c06d3891 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -162,8 +162,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
/* get a curl handle */
curl = curl_easy_init();
if (curl) {
@@ -192,12 +191,12 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
- std::string local_file = *file;
+ std::string local_file = file;
if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
+ local_file = localprefix + "/" + file;
}
std::string upload_as =
- url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
+ url + "/" + remoteprefix + cmSystemTools::GetFilenameName(file);
if (!cmSystemTools::FileExists(local_file.c_str())) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -307,12 +306,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_slist_append(nullptr, "Content-Type: text/xml");
// Add any additional headers that the user specified.
- for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
+ for (std::string const& h : this->HttpHeaders) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
/* In windows, this will init the winsock stuff */
@@ -323,18 +321,15 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
cmSystemTools::ExpandListArgument(curlopt, args);
bool verifyPeerOff = false;
bool verifyHostOff = false;
- for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
- ++i) {
- if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
+ for (std::string const& arg : args) {
+ if (arg == "CURLOPT_SSL_VERIFYPEER_OFF") {
verifyPeerOff = true;
}
- if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
+ if (arg == "CURLOPT_SSL_VERIFYHOST_OFF") {
verifyHostOff = true;
}
}
- std::string::size_type kk;
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
/* get a curl handle */
curl = curl_easy_init();
if (curl) {
@@ -389,19 +384,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- std::string local_file = *file;
+ std::string local_file = file;
if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
+ local_file = localprefix + "/" + file;
}
std::string remote_file =
- remoteprefix + cmSystemTools::GetFilenameName(*file);
+ remoteprefix + cmSystemTools::GetFilenameName(file);
*this->LogFile << "\tUpload file: " << local_file << " to "
<< remote_file << std::endl;
std::string ofile;
- for (kk = 0; kk < remote_file.size(); kk++) {
- char c = remote_file[kk];
+ for (char c : remote_file) {
char hexCh[4] = { 0, 0, 0, 0 };
hexCh[0] = c;
switch (c) {
@@ -629,8 +623,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
/* get a curl handle */
curl = curl_easy_init();
if (curl) {
@@ -670,11 +663,9 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
::curl_easy_setopt(curl, CURLOPT_FILE, &chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
- std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
+ std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(file);
std::string ofile;
- std::string::iterator kk;
- for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
- char c = *kk;
+ for (char c : rfile) {
char hexCh[4] = { 0, 0, 0, 0 };
hexCh[0] = c;
switch (c) {
@@ -772,16 +763,15 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
int problems = 0;
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
int retVal;
std::string lfname = localprefix;
cmSystemTools::ConvertToUnixSlashes(lfname);
- lfname += "/" + *file;
+ lfname += "/" + file;
lfname = cmSystemTools::ConvertToOutputPath(lfname.c_str());
argv[1] = lfname.c_str();
- std::string rfname = url + "/" + remoteprefix + *file;
+ std::string rfname = url + "/" + remoteprefix + file;
argv[2] = rfname.c_str();
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \""
<< argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2]
@@ -864,12 +854,11 @@ bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
return false;
}
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
std::string lfname = localprefix;
cmSystemTools::ConvertToUnixSlashes(lfname);
- lfname += "/" + *file;
- std::string rfname = destination + "/" + remoteprefix + *file;
+ lfname += "/" + file;
+ std::string rfname = destination + "/" + remoteprefix + file;
cmSystemTools::CopyFileAlways(lfname, rfname);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
<< lfname << " to " << rfname << std::endl,
@@ -902,13 +891,12 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
<< realURL << " (" << remoteprefix << ")" << std::endl,
this->Quiet);
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
xmlrpc_value* result;
- std::string local_file = *file;
+ std::string local_file = file;
if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
+ local_file = localprefix + "/" + file;
}
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Submit file: " << local_file << std::endl,
@@ -1323,13 +1311,11 @@ int cmCTestSubmitHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, DEBUG,
"Globbing for: " << gpath << std::endl, this->Quiet);
if (cmSystemTools::SimpleGlob(gpath, gfiles, 1)) {
- size_t cc;
- for (cc = 0; cc < gfiles.size(); cc++) {
- gfiles[cc] = gfiles[cc].substr(glen);
+ for (std::string& gfile : gfiles) {
+ gfile = gfile.substr(glen);
cmCTestOptionalLog(this->CTest, DEBUG,
- "Glob file: " << gfiles[cc] << std::endl,
- this->Quiet);
- this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
+ "Glob file: " << gfile << std::endl, this->Quiet);
+ this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile.c_str());
}
} else {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
@@ -1356,9 +1342,8 @@ int cmCTestSubmitHandler::ProcessHandler()
if (ofs) {
ofs << "Upload files:" << std::endl;
int cnt = 0;
- cmCTest::SetOfStrings::iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
- ofs << cnt << "\t" << *it << std::endl;
+ for (std::string const& file : files) {
+ ofs << cnt << "\t" << file << std::endl;
cnt++;
}
}
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 9962c49b4a..05bf4bcfd8 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -65,17 +65,16 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
this->SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator it;
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- for (it = args.begin(); it != args.end(); ++it) {
+ for (std::string const& arg : args) {
std::string fname;
- if (cmSystemTools::FileIsFullPath(it->c_str())) {
- fname = *it;
+ if (cmSystemTools::FileIsFullPath(arg.c_str())) {
+ fname = arg;
} else {
fname = cwd;
fname += "/";
- fname += *it;
+ fname += arg;
}
if (!cmSystemTools::FileIsDirectory(fname)) {
@@ -505,10 +504,9 @@ int cmCTestTestHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
<< "The following tests passed:" << std::endl,
this->Quiet);
- for (std::vector<std::string>::iterator j = passed.begin();
- j != passed.end(); ++j) {
+ for (std::string const& j : passed) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "\t" << *j << std::endl, this->Quiet);
+ "\t" << j << std::endl, this->Quiet);
}
}
@@ -518,11 +516,10 @@ int cmCTestTestHandler::ProcessHandler()
SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end());
std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests;
- for (SetOfTests::iterator ftit = resultsSet.begin();
- ftit != resultsSet.end(); ++ftit) {
- if (cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") ||
- ftit->CompletionStatus == "Disabled") {
- disabledTests.push_back(*ftit);
+ for (cmCTestTestResult const& ft : resultsSet) {
+ if (cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") ||
+ ft.CompletionStatus == "Disabled") {
+ disabledTests.push_back(ft);
}
}
@@ -555,17 +552,15 @@ int cmCTestTestHandler::ProcessHandler()
this->StartLogFile("TestsDisabled", ofs);
const char* disabled_reason;
- for (std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator dtit =
- disabledTests.begin();
- dtit != disabledTests.end(); ++dtit) {
- ofs << dtit->TestCount << ":" << dtit->Name << std::endl;
- if (dtit->CompletionStatus == "Disabled") {
+ for (cmCTestTestResult const& dt : disabledTests) {
+ ofs << dt.TestCount << ":" << dt.Name << std::endl;
+ if (dt.CompletionStatus == "Disabled") {
disabled_reason = "Disabled";
} else {
disabled_reason = "Skipped";
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t"
- << std::setw(3) << dtit->TestCount << " - " << dtit->Name
+ << std::setw(3) << dt.TestCount << " - " << dt.Name
<< " (" << disabled_reason << ")" << std::endl);
}
}
@@ -576,16 +571,14 @@ int cmCTestTestHandler::ProcessHandler()
<< "The following tests FAILED:" << std::endl);
this->StartLogFile("TestsFailed", ofs);
- for (SetOfTests::iterator ftit = resultsSet.begin();
- ftit != resultsSet.end(); ++ftit) {
- if (ftit->Status != cmCTestTestHandler::COMPLETED &&
- !cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") &&
- ftit->CompletionStatus != "Disabled") {
- ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
+ for (cmCTestTestResult const& ft : resultsSet) {
+ if (ft.Status != cmCTestTestHandler::COMPLETED &&
+ !cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") &&
+ ft.CompletionStatus != "Disabled") {
+ ofs << ft.TestCount << ":" << ft.Name << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t"
- << std::setw(3) << ftit->TestCount << " - "
- << ftit->Name << " (" << this->GetTestStatus(&*ftit)
- << ")" << std::endl);
+ << std::setw(3) << ft.TestCount << " - " << ft.Name
+ << " (" << this->GetTestStatus(ft) << ")" << std::endl);
}
}
}
@@ -629,15 +622,12 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
std::set<std::string> labels;
std::string::size_type maxlen = 0;
// initialize maps
- for (cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it) {
- cmCTestTestProperties& p = *it;
- for (std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l) {
+ for (cmCTestTestProperties& p : this->TestList) {
+ 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);
+ std::find(subprojects.begin(), subprojects.end(), l);
if (subproject != subprojects.end()) {
isSubprojectLabel = true;
}
@@ -645,27 +635,23 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
// if we are not doing sub projects and the label is not one use it
if ((doSubProject && isSubprojectLabel) ||
(!doSubProject && !isSubprojectLabel)) {
- if ((*l).size() > maxlen) {
- maxlen = (*l).size();
+ if (l.size() > maxlen) {
+ maxlen = l.size();
}
- labels.insert(*l);
- labelTimes[*l] = 0;
- labelCounts[*l] = 0;
+ labels.insert(l);
+ labelTimes[l] = 0;
+ labelCounts[l] = 0;
}
}
}
// fill maps
- for (cmCTestTestHandler::TestResultsVector::iterator ri =
- this->TestResults.begin();
- ri != this->TestResults.end(); ++ri) {
- cmCTestTestResult& result = *ri;
+ for (cmCTestTestResult& result : this->TestResults) {
cmCTestTestProperties& p = *result.Properties;
- for (std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l) {
+ for (std::string const& l : p.Labels) {
// only use labels found in labels
- if (labels.find(*l) != labels.end()) {
- labelTimes[*l] += result.ExecutionTime * result.Properties->Processors;
- ++labelCounts[*l];
+ if (labels.find(l) != labels.end()) {
+ labelTimes[l] += result.ExecutionTime * result.Properties->Processors;
+ ++labelCounts[l];
}
}
}
@@ -681,17 +667,16 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:",
this->Quiet);
}
- for (std::set<std::string>::const_iterator i = labels.begin();
- i != labels.end(); ++i) {
- std::string label = *i;
+ for (std::string const& i : labels) {
+ std::string label = i;
label.resize(maxlen + 3, ' ');
char buf[1024];
- sprintf(buf, "%6.2f sec*proc", labelTimes[*i]);
+ sprintf(buf, "%6.2f sec*proc", labelTimes[i]);
std::ostringstream labelCountStr;
- labelCountStr << "(" << labelCounts[*i] << " test";
- if (labelCounts[*i] > 1) {
+ labelCountStr << "(" << labelCounts[i] << " test";
+ if (labelCounts[i] > 1) {
labelCountStr << "s";
}
labelCountStr << ")";
@@ -700,7 +685,7 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
<< labelCountStr.str(),
this->Quiet);
if (this->LogFile) {
- *this->LogFile << "\n" << *i << " = " << buf << "\n";
+ *this->LogFile << "\n" << i << " = " << buf << "\n";
}
}
if (this->LogFile) {
@@ -724,9 +709,8 @@ void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
// check to see if the label regular expression matches
bool found = false; // assume it does not match
// loop over all labels and look for match
- for (std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l) {
- if (this->IncludeLabelRegularExpression.find(*l)) {
+ for (std::string const& l : it.Labels) {
+ if (this->IncludeLabelRegularExpression.find(l)) {
found = true;
}
}
@@ -750,9 +734,8 @@ void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it)
// check to see if the label regular expression matches
bool found = false; // assume it does not match
// loop over all labels and look for match
- for (std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l) {
- if (this->ExcludeLabelRegularExpression.find(*l)) {
+ for (std::string const& l : it.Labels) {
+ if (this->ExcludeLabelRegularExpression.find(l)) {
found = true;
}
}
@@ -781,10 +764,9 @@ void cmCTestTestHandler::ComputeTestList()
cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
// how many tests are in based on RegExp?
int inREcnt = 0;
- cmCTestTestHandler::ListOfTests::iterator it;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
- this->CheckLabelFilter(*it);
- if (it->IsInBasedOnREOptions) {
+ for (cmCTestTestProperties& tp : this->TestList) {
+ this->CheckLabelFilter(tp);
+ if (tp.IsInBasedOnREOptions) {
inREcnt++;
}
}
@@ -799,9 +781,9 @@ void cmCTestTestHandler::ComputeTestList()
inREcnt = 0;
std::string last_directory;
ListOfTests finalList;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ for (cmCTestTestProperties& tp : this->TestList) {
cnt++;
- if (it->IsInBasedOnREOptions) {
+ if (tp.IsInBasedOnREOptions) {
inREcnt++;
}
@@ -810,7 +792,7 @@ void cmCTestTestHandler::ComputeTestList()
if ((!this->TestsToRun.empty() &&
std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
this->TestsToRun.end()) &&
- !it->IsInBasedOnREOptions) {
+ !tp.IsInBasedOnREOptions) {
continue;
}
} else {
@@ -818,12 +800,12 @@ void cmCTestTestHandler::ComputeTestList()
if ((!this->TestsToRun.empty() &&
std::find(this->TestsToRun.begin(), this->TestsToRun.end(),
inREcnt) == this->TestsToRun.end()) ||
- !it->IsInBasedOnREOptions) {
+ !tp.IsInBasedOnREOptions) {
continue;
}
}
- it->Index = cnt; // save the index into the test list for this test
- finalList.push_back(*it);
+ tp.Index = cnt; // save the index into the test list for this test
+ finalList.push_back(tp);
}
UpdateForFixtures(finalList);
@@ -840,10 +822,9 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
{
this->ExpandTestsToRunInformationForRerunFailed();
- cmCTestTestHandler::ListOfTests::iterator it;
ListOfTests finalList;
int cnt = 0;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ for (cmCTestTestProperties& tp : this->TestList) {
cnt++;
// if this test is not in our list of tests to run, then skip it.
@@ -853,8 +834,8 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
continue;
}
- it->Index = cnt;
- finalList.push_back(*it);
+ tp.Index = cnt;
+ finalList.push_back(tp);
}
UpdateForFixtures(finalList);
@@ -908,24 +889,18 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
it != this->TestList.end(); ++it) {
const cmCTestTestProperties& p = *it;
- const std::set<std::string>& setups = p.FixturesSetup;
- for (std::set<std::string>::const_iterator depsIt = setups.begin();
- depsIt != setups.end(); ++depsIt) {
- fixtureSetups.insert(std::make_pair(*depsIt, it));
+ for (std::string const& deps : p.FixturesSetup) {
+ fixtureSetups.insert(std::make_pair(deps, it));
}
- const std::set<std::string>& cleanups = p.FixturesCleanup;
- for (std::set<std::string>::const_iterator depsIt = cleanups.begin();
- depsIt != cleanups.end(); ++depsIt) {
- fixtureCleanups.insert(std::make_pair(*depsIt, it));
+ for (std::string const& deps : p.FixturesCleanup) {
+ fixtureCleanups.insert(std::make_pair(deps, it));
}
}
// Prepare fast lookup of tests already included in our list of tests
std::set<std::string> addedTests;
- for (ListOfTests::const_iterator it = tests.begin(); it != tests.end();
- ++it) {
- const cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties const& p : tests) {
addedTests.insert(p.Name);
}
@@ -959,10 +934,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// Must copy the set of fixtures required because we may invalidate
// the tests array by appending to it
std::set<std::string> fixtures = tests[i].FixturesRequired;
- for (std::set<std::string>::const_iterator fixturesIt = fixtures.begin();
- fixturesIt != fixtures.end(); ++fixturesIt) {
-
- const std::string& requiredFixtureName = *fixturesIt;
+ for (std::string const& requiredFixtureName : fixtures) {
if (requiredFixtureName.empty()) {
continue;
}
@@ -1061,11 +1033,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
}
// 2. Record all setup fixtures included in the final list of tests
- for (std::set<std::string>::const_iterator fixturesIt =
- tests[i].FixturesSetup.begin();
- fixturesIt != tests[i].FixturesSetup.end(); ++fixturesIt) {
-
- const std::string& setupFixtureName = *fixturesIt;
+ for (std::string const& setupFixtureName : tests[i].FixturesSetup) {
if (setupFixtureName.empty()) {
continue;
}
@@ -1079,13 +1047,9 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// setup tests for that fixture. The latter is required to handle the
// pathological case where setup and cleanup tests are in the test set
// but no other test has that fixture as a requirement.
- for (ListOfTests::iterator tIt = tests.begin(); tIt != tests.end(); ++tIt) {
- cmCTestTestProperties& p = *tIt;
+ for (cmCTestTestProperties& p : tests) {
const std::set<std::string>& cleanups = p.FixturesCleanup;
- for (std::set<std::string>::const_iterator fIt = cleanups.begin();
- fIt != cleanups.end(); ++fIt) {
- const std::string& fixture = *fIt;
-
+ for (std::string const& fixture : cleanups) {
// 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.
@@ -1093,9 +1057,8 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
fixtureRequirements.find(fixture);
if (cIt != fixtureRequirements.end()) {
const std::vector<size_t>& indices = cIt->second;
- for (std::vector<size_t>::const_iterator indexIt = indices.begin();
- indexIt != indices.end(); ++indexIt) {
- const std::string& reqTestName = tests[*indexIt].Name;
+ for (size_t index : indices) {
+ const std::string& reqTestName = tests[index].Name;
if (std::find(p.Depends.begin(), p.Depends.end(), reqTestName) ==
p.Depends.end()) {
p.Depends.push_back(reqTestName);
@@ -1108,9 +1071,8 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
cIt = setupFixturesAdded.find(fixture);
if (cIt != setupFixturesAdded.end()) {
const std::vector<size_t>& indices = cIt->second;
- for (std::vector<size_t>::const_iterator indexIt = indices.begin();
- indexIt != indices.end(); ++indexIt) {
- const std::string& setupTestName = tests[*indexIt].Name;
+ for (size_t index : indices) {
+ const std::string& setupTestName = tests[index].Name;
if (std::find(p.Depends.begin(), p.Depends.end(), setupTestName) ==
p.Depends.end()) {
p.Depends.push_back(setupTestName);
@@ -1129,9 +1091,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
void cmCTestTestHandler::UpdateMaxTestNameWidth()
{
std::string::size_type max = this->CTest->GetMaxTestNameWidth();
- for (cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); it++) {
- cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties& p : this->TestList) {
if (max < p.Name.size()) {
max = p.Name.size();
}
@@ -1269,9 +1229,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
srand(static_cast<unsigned>(time(nullptr)));
}
- for (ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it) {
- cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties& p : this->TestList) {
cmCTestMultiProcessHandler::TestSet depends;
if (randomSchedule) {
@@ -1283,19 +1241,17 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
}
if (!p.Depends.empty()) {
- for (std::vector<std::string>::iterator i = p.Depends.begin();
- i != p.Depends.end(); ++i) {
- for (ListOfTests::iterator it2 = this->TestList.begin();
- it2 != this->TestList.end(); ++it2) {
- if (it2->Name == *i) {
- depends.insert(it2->Index);
+ for (std::string const& i : p.Depends) {
+ for (cmCTestTestProperties const& it2 : this->TestList) {
+ if (it2.Name == i) {
+ depends.insert(it2.Index);
break; // break out of test loop as name can only match 1
}
}
}
}
- tests[it->Index] = depends;
- properties[it->Index] = &*it;
+ tests[p.Index] = depends;
+ properties[p.Index] = &p;
}
parallel->SetTests(tests, properties);
parallel->SetPassFailVectors(&passed, &failed);
@@ -1333,21 +1289,18 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("StartDateTime", this->StartTest);
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
- cmCTestTestHandler::TestResultsVector::size_type cc;
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
- std::string testPath = result->Path + "/" + result->Name;
+ for (cmCTestTestResult const& result : this->TestResults) {
+ std::string testPath = result.Path + "/" + result.Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
xml.EndElement(); // TestList
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
+ for (cmCTestTestResult& result : this->TestResults) {
this->WriteTestResultHeader(xml, result);
xml.StartElement("Results");
- if (result->Status != cmCTestTestHandler::NOT_RUN) {
- if (result->Status != cmCTestTestHandler::COMPLETED ||
- result->ReturnValue) {
+ if (result.Status != cmCTestTestHandler::NOT_RUN) {
+ if (result.Status != cmCTestTestHandler::COMPLETED ||
+ result.ReturnValue) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Exit Code");
@@ -1357,24 +1310,24 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Exit Value");
- xml.Element("Value", result->ReturnValue);
+ xml.Element("Value", result.ReturnValue);
xml.EndElement(); // NamedMeasurement
}
- this->GenerateRegressionImages(xml, result->DartString);
+ this->GenerateRegressionImages(xml, result.DartString);
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "numeric/double");
xml.Attribute("name", "Execution Time");
- xml.Element("Value", result->ExecutionTime);
+ xml.Element("Value", result.ExecutionTime);
xml.EndElement(); // NamedMeasurement
- if (!result->Reason.empty()) {
+ if (!result.Reason.empty()) {
const char* reasonType = "Pass Reason";
- if (result->Status != cmCTestTestHandler::COMPLETED) {
+ if (result.Status != cmCTestTestHandler::COMPLETED) {
reasonType = "Fail Reason";
}
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", reasonType);
- xml.Element("Value", result->Reason);
+ xml.Element("Value", result.Reason);
xml.EndElement(); // NamedMeasurement
}
}
@@ -1382,36 +1335,34 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "numeric/double");
xml.Attribute("name", "Processors");
- xml.Element("Value", result->Properties->Processors);
+ xml.Element("Value", result.Properties->Processors);
xml.EndElement(); // NamedMeasurement
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Completion Status");
- xml.Element("Value", result->CompletionStatus);
+ xml.Element("Value", result.CompletionStatus);
xml.EndElement(); // NamedMeasurement
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Command Line");
- xml.Element("Value", result->FullCommandLine);
+ xml.Element("Value", result.FullCommandLine);
xml.EndElement(); // NamedMeasurement
- std::map<std::string, std::string>::iterator measureIt;
- for (measureIt = result->Properties->Measurements.begin();
- measureIt != result->Properties->Measurements.end(); ++measureIt) {
+ for (auto const& measure : result.Properties->Measurements) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
- xml.Attribute("name", measureIt->first);
- xml.Element("Value", measureIt->second);
+ xml.Attribute("name", measure.first);
+ xml.Element("Value", measure.second);
xml.EndElement(); // NamedMeasurement
}
xml.StartElement("Measurement");
xml.StartElement("Value");
- if (result->CompressOutput) {
+ if (result.CompressOutput) {
xml.Attribute("encoding", "base64");
xml.Attribute("compression", "gzip");
}
- xml.Content(result->Output);
+ xml.Content(result.Output);
xml.EndElement(); // Value
xml.EndElement(); // Measurement
xml.EndElement(); // Results
@@ -1429,32 +1380,31 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
}
void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult const& result)
{
xml.StartElement("Test");
- if (result->Status == cmCTestTestHandler::COMPLETED) {
+ if (result.Status == cmCTestTestHandler::COMPLETED) {
xml.Attribute("Status", "passed");
- } else if (result->Status == cmCTestTestHandler::NOT_RUN) {
+ } else if (result.Status == cmCTestTestHandler::NOT_RUN) {
xml.Attribute("Status", "notrun");
} else {
xml.Attribute("Status", "failed");
}
- std::string testPath = result->Path + "/" + result->Name;
- xml.Element("Name", result->Name);
- xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
+ std::string testPath = result.Path + "/" + result.Name;
+ xml.Element("Name", result.Name);
+ xml.Element("Path", this->CTest->GetShortPathToFile(result.Path.c_str()));
xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str()));
- xml.Element("FullCommandLine", result->FullCommandLine);
+ xml.Element("FullCommandLine", result.FullCommandLine);
}
void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult const& result)
{
- if (!result->Properties->Labels.empty()) {
+ if (!result.Properties->Labels.empty()) {
xml.StartElement("Labels");
- std::vector<std::string> const& labels = result->Properties->Labels;
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- xml.Element("Label", *li);
+ std::vector<std::string> const& labels = result.Properties->Labels;
+ for (std::string const& label : labels) {
+ xml.Element("Label", label);
}
xml.EndElement(); // Labels
}
@@ -1463,20 +1413,18 @@ void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
}
void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult& result)
{
- if (result->Status != cmCTestTestHandler::COMPLETED &&
- !result->Properties->AttachOnFail.empty()) {
- result->Properties->AttachedFiles.insert(
- result->Properties->AttachedFiles.end(),
- result->Properties->AttachOnFail.begin(),
- result->Properties->AttachOnFail.end());
- }
- for (std::vector<std::string>::const_iterator file =
- result->Properties->AttachedFiles.begin();
- file != result->Properties->AttachedFiles.end(); ++file) {
- const std::string& base64 = this->CTest->Base64GzipEncodeFile(*file);
- std::string fname = cmSystemTools::GetFilenameName(*file);
+ if (result.Status != cmCTestTestHandler::COMPLETED &&
+ !result.Properties->AttachOnFail.empty()) {
+ result.Properties->AttachedFiles.insert(
+ result.Properties->AttachedFiles.end(),
+ result.Properties->AttachOnFail.begin(),
+ result.Properties->AttachOnFail.end());
+ }
+ for (std::string const& file : result.Properties->AttachedFiles) {
+ const std::string& base64 = this->CTest->Base64GzipEncodeFile(file);
+ std::string const fname = cmSystemTools::GetFilenameName(file);
xml.StartElement("NamedMeasurement");
xml.Attribute("name", "Attached File");
xml.Attribute("encoding", "base64");
@@ -1490,18 +1438,16 @@ void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
{
- std::vector<std::string>::iterator it;
- for (it = vec.begin(); it != vec.end(); ++it) {
+ for (std::string const& it : vec) {
int retVal = 0;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run command: " << *it << std::endl, this->Quiet);
- if (!cmSystemTools::RunSingleCommand(it->c_str(), nullptr, nullptr,
- &retVal, nullptr,
- cmSystemTools::OUTPUT_MERGE
+ "Run command: " << it << std::endl, this->Quiet);
+ if (!cmSystemTools::RunSingleCommand(it.c_str(), nullptr, nullptr, &retVal,
+ nullptr, cmSystemTools::OUTPUT_MERGE
/*this->Verbose*/) ||
retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running command: " << *it << std::endl);
+ "Problem running command: " << it << std::endl);
return 0;
}
}
@@ -1612,11 +1558,9 @@ std::string cmCTestTestHandler::FindExecutable(
// if extraPaths are provided and we were not passed a full path, try them,
// try any extra paths
if (filepath.empty()) {
- for (unsigned int i = 0; i < extraPaths.size(); ++i) {
- std::string filepathExtra =
- cmSystemTools::GetFilenamePath(extraPaths[i]);
- std::string filenameExtra =
- cmSystemTools::GetFilenameName(extraPaths[i]);
+ for (std::string const& extraPath : extraPaths) {
+ std::string filepathExtra = cmSystemTools::GetFilenamePath(extraPath);
+ std::string filenameExtra = cmSystemTools::GetFilenameName(extraPath);
cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
filepathExtra, filenameExtra);
}
@@ -1661,9 +1605,8 @@ std::string cmCTestTestHandler::FindExecutable(
cmCTestLog(ctest, HANDLER_OUTPUT, "Could not find executable "
<< testCommand << "\n"
<< "Looked in the following places:\n");
- for (std::vector<std::string>::iterator i = failed.begin();
- i != failed.end(); ++i) {
- cmCTestLog(ctest, HANDLER_OUTPUT, *i << "\n");
+ for (std::string const& f : failed) {
+ cmCTestLog(ctest, HANDLER_OUTPUT, f << "\n");
}
}
@@ -1757,19 +1700,19 @@ void cmCTestTestHandler::UseExcludeRegExp()
this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
}
-const char* cmCTestTestHandler::GetTestStatus(const cmCTestTestResult* result)
+const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
{
static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT",
"ILLEGAL", "INTERRUPT", "NUMERICAL",
"OTHER_FAULT", "Failed", "BAD_COMMAND",
"Completed" };
- int status = result->Status;
+ int status = result.Status;
if (status < cmCTestTestHandler::NOT_RUN ||
status > cmCTestTestHandler::COMPLETED) {
return "No Status";
}
if (status == cmCTestTestHandler::OTHER_FAULT) {
- return result->ExceptionStatus.c_str();
+ return result.ExceptionStatus.c_str();
}
return statuses[status];
}
@@ -2153,125 +2096,117 @@ bool cmCTestTestHandler::SetTestsProperties(
break;
}
std::string val = *it;
- std::vector<std::string>::const_iterator tit;
- for (tit = tests.begin(); tit != tests.end(); ++tit) {
- cmCTestTestHandler::ListOfTests::iterator rtit;
- for (rtit = this->TestList.begin(); rtit != this->TestList.end();
- ++rtit) {
- if (*tit == rtit->Name) {
+ for (std::string const& t : tests) {
+ for (cmCTestTestProperties& rt : this->TestList) {
+ if (t == rt.Name) {
if (key == "WILL_FAIL") {
- rtit->WillFail = cmSystemTools::IsOn(val.c_str());
+ rt.WillFail = cmSystemTools::IsOn(val.c_str());
}
if (key == "DISABLED") {
- rtit->Disabled = cmSystemTools::IsOn(val.c_str());
+ rt.Disabled = cmSystemTools::IsOn(val.c_str());
}
if (key == "ATTACHED_FILES") {
- cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles);
+ cmSystemTools::ExpandListArgument(val, rt.AttachedFiles);
}
if (key == "ATTACHED_FILES_ON_FAIL") {
- cmSystemTools::ExpandListArgument(val, rtit->AttachOnFail);
+ cmSystemTools::ExpandListArgument(val, rt.AttachOnFail);
}
if (key == "RESOURCE_LOCK") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- rtit->LockedResources.insert(lval.begin(), lval.end());
+ rt.LockedResources.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_SETUP") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- rtit->FixturesSetup.insert(lval.begin(), lval.end());
+ rt.FixturesSetup.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_CLEANUP") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- rtit->FixturesCleanup.insert(lval.begin(), lval.end());
+ rt.FixturesCleanup.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_REQUIRED") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- rtit->FixturesRequired.insert(lval.begin(), lval.end());
+ rt.FixturesRequired.insert(lval.begin(), lval.end());
}
if (key == "TIMEOUT") {
- rtit->Timeout = atof(val.c_str());
- rtit->ExplicitTimeout = true;
+ rt.Timeout = atof(val.c_str());
+ rt.ExplicitTimeout = true;
}
if (key == "COST") {
- rtit->Cost = static_cast<float>(atof(val.c_str()));
+ rt.Cost = static_cast<float>(atof(val.c_str()));
}
if (key == "REQUIRED_FILES") {
- cmSystemTools::ExpandListArgument(val, rtit->RequiredFiles);
+ cmSystemTools::ExpandListArgument(val, rt.RequiredFiles);
}
if (key == "RUN_SERIAL") {
- rtit->RunSerial = cmSystemTools::IsOn(val.c_str());
+ rt.RunSerial = cmSystemTools::IsOn(val.c_str());
}
if (key == "FAIL_REGULAR_EXPRESSION") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->ErrorRegularExpressions.push_back(
+ for (std::string const& cr : lval) {
+ rt.ErrorRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ cmsys::RegularExpression(cr.c_str()), std::string(cr)));
}
}
if (key == "PROCESSORS") {
- rtit->Processors = atoi(val.c_str());
- if (rtit->Processors < 1) {
- rtit->Processors = 1;
+ rt.Processors = atoi(val.c_str());
+ if (rt.Processors < 1) {
+ rt.Processors = 1;
}
}
if (key == "SKIP_RETURN_CODE") {
- rtit->SkipReturnCode = atoi(val.c_str());
- if (rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) {
- rtit->SkipReturnCode = -1;
+ rt.SkipReturnCode = atoi(val.c_str());
+ if (rt.SkipReturnCode < 0 || rt.SkipReturnCode > 255) {
+ rt.SkipReturnCode = -1;
}
}
if (key == "DEPENDS") {
- cmSystemTools::ExpandListArgument(val, rtit->Depends);
+ cmSystemTools::ExpandListArgument(val, rt.Depends);
}
if (key == "ENVIRONMENT") {
- cmSystemTools::ExpandListArgument(val, rtit->Environment);
+ cmSystemTools::ExpandListArgument(val, rt.Environment);
}
if (key == "LABELS") {
std::vector<std::string> Labels;
cmSystemTools::ExpandListArgument(val, Labels);
- rtit->Labels.insert(rtit->Labels.end(), Labels.begin(),
- Labels.end());
+ rt.Labels.insert(rt.Labels.end(), Labels.begin(), Labels.end());
// sort the array
- std::sort(rtit->Labels.begin(), rtit->Labels.end());
+ std::sort(rt.Labels.begin(), rt.Labels.end());
// remove duplicates
std::vector<std::string>::iterator new_end =
- std::unique(rtit->Labels.begin(), rtit->Labels.end());
- rtit->Labels.erase(new_end, rtit->Labels.end());
+ std::unique(rt.Labels.begin(), rt.Labels.end());
+ rt.Labels.erase(new_end, rt.Labels.end());
}
if (key == "MEASUREMENT") {
size_t pos = val.find_first_of('=');
if (pos != std::string::npos) {
std::string mKey = val.substr(0, pos);
const char* mVal = val.c_str() + pos + 1;
- rtit->Measurements[mKey] = mVal;
+ rt.Measurements[mKey] = mVal;
} else {
- rtit->Measurements[val] = "1";
+ rt.Measurements[val] = "1";
}
}
if (key == "PASS_REGULAR_EXPRESSION") {
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->RequiredRegularExpressions.push_back(
+ for (std::string const& cr : lval) {
+ rt.RequiredRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ cmsys::RegularExpression(cr.c_str()), std::string(cr)));
}
}
if (key == "WORKING_DIRECTORY") {
- rtit->Directory = val;
+ rt.Directory = val;
}
if (key == "TIMEOUT_AFTER_MATCH") {
std::vector<std::string> propArgs;
@@ -2281,15 +2216,13 @@ bool cmCTestTestHandler::SetTestsProperties(
"TIMEOUT_AFTER_MATCH expects two arguments, found "
<< propArgs.size() << std::endl);
} else {
- rtit->AlternateTimeout = atof(propArgs[0].c_str());
+ rt.AlternateTimeout = atof(propArgs[0].c_str());
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(propArgs[1], lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->TimeoutRegularExpressions.push_back(
+ for (std::string const& cr : lval) {
+ rt.TimeoutRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ cmsys::RegularExpression(cr.c_str()), std::string(cr)));
}
}
}
@@ -2325,22 +2258,21 @@ bool cmCTestTestHandler::SetDirectoryProperties(
break;
}
std::string val = *it;
- cmCTestTestHandler::ListOfTests::iterator rtit;
- for (rtit = this->TestList.begin(); rtit != this->TestList.end(); ++rtit) {
+ for (cmCTestTestProperties& rt : this->TestList) {
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- if (cwd == rtit->Directory) {
+ if (cwd == rt.Directory) {
if (key == "LABELS") {
std::vector<std::string> DirectoryLabels;
cmSystemTools::ExpandListArgument(val, DirectoryLabels);
- rtit->Labels.insert(rtit->Labels.end(), DirectoryLabels.begin(),
- DirectoryLabels.end());
+ rt.Labels.insert(rt.Labels.end(), DirectoryLabels.begin(),
+ DirectoryLabels.end());
// sort the array
- std::sort(rtit->Labels.begin(), rtit->Labels.end());
+ std::sort(rt.Labels.begin(), rt.Labels.end());
// remove duplicates
std::vector<std::string>::iterator new_end =
- std::unique(rtit->Labels.begin(), rtit->Labels.end());
- rtit->Labels.erase(new_end, rtit->Labels.end());
+ std::unique(rt.Labels.begin(), rt.Labels.end());
+ rt.Labels.erase(new_end, rt.Labels.end());
}
}
}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 4c5b55fb3f..eaa7a33716 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -188,10 +188,12 @@ protected:
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
int ExecuteCommands(std::vector<std::string>& vec);
- void WriteTestResultHeader(cmXMLWriter& xml, cmCTestTestResult* result);
- void WriteTestResultFooter(cmXMLWriter& xml, cmCTestTestResult* result);
+ void WriteTestResultHeader(cmXMLWriter& xml,
+ cmCTestTestResult const& result);
+ void WriteTestResultFooter(cmXMLWriter& xml,
+ cmCTestTestResult const& result);
// Write attached test files into the xml
- void AttachFiles(cmXMLWriter& xml, cmCTestTestResult* result);
+ void AttachFiles(cmXMLWriter& xml, cmCTestTestResult& result);
//! Clean test output to specified length
bool CleanTestOutput(std::string& output, size_t length);
@@ -269,7 +271,7 @@ private:
*/
std::string FindTheExecutable(const char* exe);
- const char* GetTestStatus(const cmCTestTestResult*);
+ const char* GetTestStatus(cmCTestTestResult const&);
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index 05a39840da..59a5de4845 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -7,7 +7,6 @@
#include "cmXMLWriter.h"
#include <ostream>
-#include <set>
#include <string>
cmCTestUploadHandler::cmCTestUploadHandler()
@@ -37,7 +36,6 @@ int cmCTestUploadHandler::ProcessHandler()
}
std::string buildname =
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
- cmCTest::SetOfStrings::const_iterator it;
cmXMLWriter xml(ofs);
xml.StartDocument();
@@ -55,14 +53,14 @@ int cmCTestUploadHandler::ProcessHandler()
this->CTest->AddSiteProperties(xml);
xml.StartElement("Upload");
- for (it = this->Files.begin(); it != this->Files.end(); it++) {
+ for (std::string const& file : this->Files) {
cmCTestOptionalLog(this->CTest, OUTPUT,
- "\tUpload file: " << *it << std::endl, this->Quiet);
+ "\tUpload file: " << file << std::endl, this->Quiet);
xml.StartElement("File");
- xml.Attribute("filename", *it);
+ xml.Attribute("filename", file);
xml.StartElement("Content");
xml.Attribute("encoding", "base64");
- xml.Content(this->CTest->Base64EncodeFile(*it));
+ xml.Content(this->CTest->Base64EncodeFile(file));
xml.EndElement(); // Content
xml.EndElement(); // File
}
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 186d2d4a97..7e09ef0f3f 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -56,9 +56,8 @@ bool cmCTestVC::InitialCheckout(const char* command)
// Construct the initial checkout command line.
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
std::vector<char const*> vc_co;
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- vc_co.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ vc_co.push_back(arg.c_str());
}
vc_co.push_back(nullptr);
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
index 83a7b75eb3..308e6f7a35 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.cxx
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -112,17 +112,15 @@ cmParseBlanketJSCoverage::cmParseBlanketJSCoverage(
bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
{
- size_t i = 0;
- std::string path;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found " << files.size() << " Files" << std::endl,
this->Coverage.Quiet);
- for (i = 0; i < files.size(); i++) {
+ for (std::string const& file : files) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Reading JSON File " << files[i] << std::endl,
+ "Reading JSON File " << file << std::endl,
this->Coverage.Quiet);
- if (!this->ReadJSONFile(files[i])) {
+ if (!this->ReadJSONFile(file)) {
return false;
}
}
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index 629010cf14..bf03c4589f 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -53,10 +53,8 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
while (ci != this->Coverage.TotalCoverage.end()) {
cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second;
bool nothing = true;
- for (cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator
- i = v.begin();
- i != v.end(); ++i) {
- if (*i > 0) {
+ for (int i : v) {
+ if (i > 0) {
nothing = false;
break;
}
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index 4a16a4867a..71eb4678e3 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -71,8 +71,8 @@ protected:
// Check if this is an absolute path that falls within our
// source or binary directories.
- for (size_t i = 0; i < FilePaths.size(); i++) {
- if (filename.find(FilePaths[i]) == 0) {
+ for (std::string const& filePath : FilePaths) {
+ if (filename.find(filePath) == 0) {
this->CurFileName = filename;
break;
}
@@ -81,8 +81,8 @@ protected:
if (this->CurFileName == "") {
// Check if this is a path that is relative to our source or
// binary directories.
- for (size_t i = 0; i < FilePaths.size(); i++) {
- finalpath = FilePaths[i] + "/" + filename;
+ for (std::string const& filePath : FilePaths) {
+ finalpath = filePath + "/" + filename;
if (cmSystemTools::FileExists(finalpath.c_str())) {
this->CurFileName = finalpath;
break;
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index 6d884ef336..1bd24b4425 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -119,9 +119,8 @@ protected:
}
// Check if any of the locations found match our package.
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
+ for (std::string const& f : files) {
+ std::string dir = cmsys::SystemTools::GetParentDirectory(f);
if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found package directory for " << fileName << ": "
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index 8cb1170e4a..1419743fc5 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -9,7 +9,6 @@
#include <map>
#include <string>
#include <utility>
-#include <vector>
cmParseMumpsCoverage::cmParseMumpsCoverage(
cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
@@ -112,14 +111,12 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
std::string pat = d;
pat += "/*.m";
glob.FindFiles(pat);
- std::vector<std::string>& files = glob.GetFiles();
- std::vector<std::string>::iterator fileIt;
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
- std::string name = cmSystemTools::GetFilenameName(*fileIt);
- this->RoutineToDirectory[name.substr(0, name.size() - 2)] = *fileIt;
+ for (std::string& file : glob.GetFiles()) {
+ std::string name = cmSystemTools::GetFilenameName(file);
+ this->RoutineToDirectory[name.substr(0, name.size() - 2)] = file;
// initialze each file, this is left out until CDash is fixed
// to handle large numbers of files
- this->InitializeMumpsFile(*fileIt);
+ this->InitializeMumpsFile(file);
}
return true;
}
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 5ada25d28f..f3c191b8a0 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -40,9 +40,8 @@ bool cmProcess::StartProcess()
// put the command as arg0
this->ProcessArgs.push_back(this->Command.c_str());
// now put the command arguments in
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
- this->ProcessArgs.push_back(i->c_str());
+ for (std::string const& arg : this->Arguments) {
+ this->ProcessArgs.push_back(arg.c_str());
}
this->ProcessArgs.push_back(nullptr); // null terminate the list
this->Process = cmsysProcess_New();
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index a164b37914..1325fd32a8 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -330,10 +330,8 @@ cmCTest::cmCTest()
this->TestingHandlers["submit"] = new cmCTestSubmitHandler;
this->TestingHandlers["upload"] = new cmCTestUploadHandler;
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetCTestInstance(this);
+ for (auto& handler : this->TestingHandlers) {
+ handler.second->SetCTestInstance(this);
}
// Make sure we can capture the build tool output.
@@ -979,9 +977,11 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
output = "";
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
- std::vector<const char*>::iterator ait;
- for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\"");
+ for (char const* arg : argv) {
+ if (!arg) {
+ break;
+ }
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << arg << "\"");
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl);
@@ -1365,12 +1365,10 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
void cmCTest::GenerateSubprojectsOutput(cmXMLWriter& xml)
{
- std::vector<std::string> subprojects = this->GetLabelsForSubprojects();
- std::vector<std::string>::const_iterator i;
- for (i = subprojects.begin(); i != subprojects.end(); ++i) {
+ for (std::string const& subproj : this->GetLabelsForSubprojects()) {
xml.StartElement("Subproject");
- xml.Attribute("name", *i);
- xml.Element("Label", *i);
+ xml.Attribute("name", subproj);
+ xml.Element("Label", subproj);
xml.EndElement(); // Subproject
}
}
@@ -1403,7 +1401,6 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
{
std::string buildname =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
- cmCTest::VectorOfStrings::const_iterator it;
xml.StartDocument();
xml.ProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" "
@@ -1419,15 +1416,15 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
this->AddSiteProperties(xml);
xml.StartElement("Notes");
- for (it = files.begin(); it != files.end(); it++) {
- cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
+ for (cmsys::String const& file : files) {
+ cmCTestLog(this, OUTPUT, "\tAdd file: " << file << std::endl);
std::string note_time = this->CurrentTime();
xml.StartElement("Note");
- xml.Attribute("Name", *it);
+ xml.Attribute("Name", file);
xml.Element("Time", cmSystemTools::GetTime());
xml.Element("DateTime", note_time);
xml.StartElement("Text");
- cmsys::ifstream ifs(it->c_str());
+ cmsys::ifstream ifs(file.c_str());
if (ifs) {
std::string line;
while (cmSystemTools::GetLineFromStream(ifs, line)) {
@@ -1436,9 +1433,9 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
}
ifs.close();
} else {
- xml.Content("Problem reading file: " + *it + "\n");
+ xml.Content("Problem reading file: " + file + "\n");
cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: "
- << *it << " while creating notes" << std::endl);
+ << file << " while creating notes" << std::endl);
}
xml.EndElement(); // Text
xml.EndElement(); // Note
@@ -1520,14 +1517,13 @@ std::string cmCTest::Base64EncodeFile(std::string const& file)
bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)
{
- VectorOfStrings::const_iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
- if (!cmSystemTools::FileExists(it->c_str())) {
+ for (cmsys::String const& file : files) {
+ if (!cmSystemTools::FileExists(file.c_str())) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
- << *it << " to submit." << std::endl;);
+ << file << " to submit." << std::endl;);
return false;
}
- this->AddSubmitFile(PartExtraFiles, it->c_str());
+ this->AddSubmitFile(PartExtraFiles, file.c_str());
}
return true;
}
@@ -2101,10 +2097,8 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// pass the argument to all the handlers as well, but i may no longer be
// set to what it was originally so I'm not sure this is working as
// intended
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- if (!it->second->ProcessCommandLineArguments(arg, i, args)) {
+ for (auto& handler : this->TestingHandlers) {
+ if (!handler.second->ProcessCommandLineArguments(arg, i, args)) {
cmCTestLog(this, ERROR_MESSAGE,
"Problem parsing command line arguments within a handler");
return 0;
@@ -2201,11 +2195,9 @@ int cmCTest::ExecuteTests()
if (this->ExtraVerbose) {
cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl);
}
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetVerbose(this->ExtraVerbose);
- it->second->SetSubmitIndex(this->SubmitIndex);
+ for (auto& handler : this->TestingHandlers) {
+ handler.second->SetVerbose(this->ExtraVerbose);
+ handler.second->SetSubmitIndex(this->SubmitIndex);
}
this->GetHandler("script")->SetVerbose(this->Verbose);
res = this->GetHandler("script")->ProcessHandler();
@@ -2219,11 +2211,9 @@ int cmCTest::ExecuteTests()
// and Verbose is always on in this case
this->ExtraVerbose = this->Verbose;
this->Verbose = true;
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetVerbose(this->Verbose);
- it->second->SetSubmitIndex(this->SubmitIndex);
+ for (auto& handler : this->TestingHandlers) {
+ handler.second->SetVerbose(this->Verbose);
+ handler.second->SetSubmitIndex(this->SubmitIndex);
}
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
if (!this->Initialize(cwd.c_str(), nullptr)) {
@@ -2324,13 +2314,11 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
}
if (found) {
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- cmCTestLog(this, DEBUG,
- "* Read custom CTest configuration vectors for handler: "
- << it->first << " (" << it->second << ")" << std::endl);
- it->second->PopulateCustomVectors(mf);
+ for (auto& handler : this->TestingHandlers) {
+ cmCTestLog(
+ this, DEBUG, "* Read custom CTest configuration vectors for handler: "
+ << handler.first << " (" << handler.second << ")" << std::endl);
+ handler.second->PopulateCustomVectors(mf);
}
}