summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx115
1 files changed, 49 insertions, 66 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 66b8f07..1325fd3 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -222,8 +222,7 @@ std::string cmCTest::MakeURLSafe(const std::string& str)
{
std::ostringstream ost;
char buffer[10];
- for (std::string::size_type pos = 0; pos < str.size(); pos++) {
- unsigned char ch = str[pos];
+ for (unsigned char ch : str) {
if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
ch == '=' || ch == '@') &&
ch != 9) {
@@ -331,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.
@@ -973,17 +970,18 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
}
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& a : args) {
+ argv.push_back(a.c_str());
}
argv.push_back(nullptr);
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);
@@ -1009,9 +1007,9 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
<< " " << std::flush);
while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
processOutput.DecodeText(data, length, strdata);
- for (size_t cc = 0; cc < strdata.size(); ++cc) {
- if (strdata[cc] == 0) {
- strdata[cc] = '\n';
+ for (char& cc : strdata) {
+ if (cc == 0) {
+ cc = '\n';
}
}
output.append(strdata);
@@ -1107,18 +1105,18 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
inst.SetStreams(&oss, &oss);
std::vector<std::string> args;
- for (unsigned int i = 0; i < argv.size(); ++i) {
- if (argv[i]) {
+ for (char const* i : argv) {
+ if (i) {
// make sure we pass the timeout in for any build and test
// invocations. Since --build-generator is required this is a
// good place to check for it, and to add the arguments in
- if (strcmp(argv[i], "--build-generator") == 0 && timeout > 0) {
+ if (strcmp(i, "--build-generator") == 0 && timeout > 0) {
args.push_back("--test-timeout");
std::ostringstream msg;
msg << timeout;
args.push_back(msg.str());
}
- args.push_back(argv[i]);
+ args.push_back(i);
}
}
if (log) {
@@ -1348,9 +1346,8 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
std::string l = labels;
std::vector<std::string> args;
cmSystemTools::ExpandListArgument(l, args);
- for (std::vector<std::string>::iterator i = args.begin();
- i != args.end(); ++i) {
- xml.Element("Label", *i);
+ for (std::string const& i : args) {
+ xml.Element("Label", i);
}
xml.EndElement();
}
@@ -1368,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
}
}
@@ -1406,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\" "
@@ -1422,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)) {
@@ -1439,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
@@ -1523,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;
}
@@ -2104,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;
@@ -2204,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();
@@ -2222,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)) {
@@ -2327,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);
}
}
@@ -2352,9 +2337,8 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
vec.clear();
cmSystemTools::ExpandListArgument(dval, vec);
- for (std::vector<std::string>::const_iterator it = vec.begin();
- it != vec.end(); ++it) {
- cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
+ for (std::string const& it : vec) {
+ cmCTestLog(this, DEBUG, " -- " << it << std::endl);
}
}
@@ -2592,9 +2576,8 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
}
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& a : args) {
+ argv.push_back(a.c_str());
}
argv.push_back(nullptr);