diff options
Diffstat (limited to 'Source/CTest/cmCTestBuildAndTestHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index cc29071..a0d68a0 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -32,7 +32,7 @@ const char* cmCTestBuildAndTestHandler::GetOutput() } int cmCTestBuildAndTestHandler::ProcessHandler() { - this->Output = ""; + this->Output.clear(); std::string output; cmSystemTools::ResetErrorOccuredFlag(); int retv = this->RunCMakeAndTest(&this->Output); @@ -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); @@ -65,7 +64,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, args.push_back(toolset); } - const char* config = CM_NULLPTR; + const char* config = nullptr; if (!this->CTest->GetConfigType().empty()) { config = this->CTest->GetConfigType().c_str(); } @@ -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"; @@ -115,21 +114,21 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, void CMakeMessageCallback(const char* m, const char* /*unused*/, bool& /*unused*/, void* s) { - std::string* out = (std::string*)s; + std::string* out = static_cast<std::string*>(s); *out += m; *out += "\n"; } void CMakeProgressCallback(const char* msg, float /*unused*/, void* s) { - std::string* out = (std::string*)s; + std::string* out = static_cast<std::string*>(s); *out += msg; *out += "\n"; } void CMakeOutputCallback(const char* m, size_t len, void* s) { - std::string* out = (std::string*)s; + std::string* out = static_cast<std::string*>(s); out->append(m, len); } @@ -148,10 +147,10 @@ public: } ~cmCTestBuildAndTestCaptureRAII() { - this->CM.SetProgressCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetStderrCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetStdoutCallback(CM_NULLPTR, CM_NULLPTR); - cmSystemTools::SetMessageCallback(CM_NULLPTR, CM_NULLPTR); + this->CM.SetProgressCallback(nullptr, nullptr); + cmSystemTools::SetStderrCallback(nullptr, nullptr); + cmSystemTools::SetStdoutCallback(nullptr, nullptr); + cmSystemTools::SetMessageCallback(nullptr, nullptr); } }; @@ -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; @@ -236,7 +233,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } } std::string output; - const char* config = CM_NULLPTR; + const char* config = nullptr; if (!this->CTest->GetConfigType().empty()) { config = this->CTest->GetConfigType().c_str(); } @@ -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,10 +302,10 @@ 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(CM_NULLPTR); + testCommand.push_back(nullptr); std::string outs; int retval = 0; // run the test from the this->BuildRunDir if set @@ -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"; @@ -334,8 +331,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } } - int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, - CM_NULLPTR, remainingTime, CM_NULLPTR); + int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, nullptr, + remainingTime, nullptr); if (runTestRes != cmsysProcess_State_Exited || retval != 0) { out << "Test command failed: " << testCommand[0] << "\n"; |