diff options
Diffstat (limited to 'Source/CTest')
62 files changed, 779 insertions, 477 deletions
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 381c70c..3014a93 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -225,35 +225,35 @@ private: return true; } - virtual void StartElement(const char* name, const char**) + virtual void StartElement(const std::string& name, const char**) { this->CData.clear(); - if(strcmp(name, "log") == 0) + if(name == "log") { this->Rev = Revision(); this->Changes.clear(); } // affected-files can contain blocks of // modified, unknown, renamed, kind-changed, removed, conflicts, added - else if(strcmp(name, "modified") == 0 - || strcmp(name, "renamed") == 0 - || strcmp(name, "kind-changed") == 0) + else if(name == "modified" + || name == "renamed" + || name == "kind-changed") { this->CurChange = Change(); this->CurChange.Action = 'M'; } - else if(strcmp(name, "added") == 0) + else if(name == "added") { this->CurChange = Change(); this->CurChange = 'A'; } - else if(strcmp(name, "removed") == 0) + else if(name == "removed") { this->CurChange = Change(); this->CurChange = 'D'; } - else if(strcmp(name, "unknown") == 0 - || strcmp(name, "conflicts") == 0) + else if(name == "unknown" + || name == "conflicts") { // Should not happen here this->CurChange = Change(); @@ -265,27 +265,27 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "log") == 0) + if(name == "log") { this->BZR->DoRevision(this->Rev, this->Changes); } - else if((strcmp(name, "file") == 0 || strcmp(name, "directory") == 0) - && !this->CData.empty()) + else if(!this->CData.empty() && + (name == "file" || name == "directory")) { this->CurChange.Path.assign(&this->CData[0], this->CData.size()); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "symlink") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "symlink") { // symlinks have an arobase at the end in the log this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "committer") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "committer") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); if(this->EmailRegex.find(this->Rev.Author)) @@ -294,15 +294,15 @@ private: this->Rev.EMail = this->EmailRegex.match(2); } } - else if(strcmp(name, "timestamp") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "timestamp") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "message") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "message") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "revno") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "revno") { this->Rev.Rev.assign(&this->CData[0], this->CData.size()); } @@ -409,7 +409,7 @@ bool cmCTestBZR::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -418,7 +418,7 @@ bool cmCTestBZR::UpdateImpl() bzr_update.push_back(this->CommandLineTool.c_str()); bzr_update.push_back("pull"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { bzr_update.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 0fac136..4a3eec5 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) { // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( - this->BuildGenerator.c_str())); + this->BuildGenerator)); cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. - cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str()); + cm.GetCacheManager()->LoadCache(this->BinaryDir); } else { @@ -295,9 +295,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) config = "Debug"; } int retVal = cm.GetGlobalGenerator()->Build( - this->SourceDir.c_str(), this->BinaryDir.c_str(), - this->BuildProject.c_str(), tarIt->c_str(), - &output, this->BuildMakeProgram.c_str(), + this->SourceDir, this->BinaryDir, + this->BuildProject, *tarIt, + &output, this->BuildMakeProgram, config, !this->BuildNoClean, false, remainingTime); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index ca50c64..d1e9a4d 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -54,7 +54,7 @@ protected: std::string &cmakeOutString, std::string &cwd, cmake *cm); - cmStdString Output; + std::string Output; std::string BuildGenerator; std::string BuildGeneratorToolset; diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 12ff718..f81083a 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -101,8 +101,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } if ( this->GlobalGenerator ) { - if ( strcmp(this->GlobalGenerator->GetName(), - cmakeGeneratorName) != 0 ) + if ( this->GlobalGenerator->GetName() != cmakeGeneratorName ) { delete this->GlobalGenerator; this->GlobalGenerator = 0; @@ -130,11 +129,12 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator-> - GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, - cmakeBuildAdditionalFlags, true); + GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "", + cmakeBuildConfiguration, + cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" - << buildCommand.c_str() << "\n"); + << buildCommand << "\n"); this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); } else @@ -151,7 +151,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() "\n" "Alternatively, set CTEST_BUILD_COMMAND to build the project " "with a custom command line."; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return 0; } } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 08887fe..2632ebc 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_build";} + virtual std::string GetName() const { return "ctest_build";} virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c5deb96..7922c9a 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -380,7 +380,7 @@ int cmCTestBuildHandler::ProcessHandler() // Create lists of regular expression strings for errors, error exceptions, // warnings and warning exceptions. - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ ) { this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); @@ -400,7 +400,7 @@ int cmCTestBuildHandler::ProcessHandler() } // Pre-compile regular expressions objects for all regular expressions - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \ regexes.clear(); \ @@ -409,7 +409,7 @@ int cmCTestBuildHandler::ProcessHandler() for ( it = strings.begin(); it != strings.end(); ++it ) \ { \ cmCTestLog(this->CTest, DEBUG, "Add " #strings ": " \ - << it->c_str() << std::endl); \ + << *it << std::endl); \ regexes.push_back(it->c_str()); \ } cmCTestBuildHandlerPopulateRegexVector( @@ -602,7 +602,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os) // Sort XML fragments in chronological order. cmFileTimeComparison ftc; FragmentCompare fragmentCompare(&ftc); - typedef std::set<cmStdString, FragmentCompare> Fragments; + typedef std::set<std::string, FragmentCompare> Fragments; Fragments fragments(fragmentCompare); // Identify fragments on disk. @@ -889,7 +889,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -897,7 +897,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, } std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = args.begin(); + for(std::vector<std::string>::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); @@ -1133,7 +1133,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, errorwarning.PostContext = ""; // Copy pre-context to report - std::deque<cmStdString>::iterator pcit; + std::deque<std::string>::iterator pcit; for ( pcit = this->PreContext.begin(); pcit != this->PreContext.end(); ++pcit ) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index ff7cfd6..09346f9 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -97,10 +97,10 @@ private: double StartBuildTime; double EndBuildTime; - std::vector<cmStdString> CustomErrorMatches; - std::vector<cmStdString> CustomErrorExceptions; - std::vector<cmStdString> CustomWarningMatches; - std::vector<cmStdString> CustomWarningExceptions; + std::vector<std::string> CustomErrorMatches; + std::vector<std::string> CustomErrorExceptions; + std::vector<std::string> CustomWarningMatches; + std::vector<std::string> CustomWarningExceptions; std::vector<std::string> ReallyCustomWarningMatches; std::vector<std::string> ReallyCustomWarningExceptions; std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex; @@ -121,8 +121,8 @@ private: size_t BuildOutputLogSize; std::vector<char> CurrentProcessingLine; - cmStdString SimplifySourceDir; - cmStdString SimplifyBuildDir; + std::string SimplifySourceDir; + std::string SimplifyBuildDir; size_t OutputLineCounter; typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector; t_ErrorsAndWarningsVector ErrorsAndWarnings; @@ -130,7 +130,7 @@ private: size_t PostContextCount; size_t MaxPreContext; size_t MaxPostContext; - std::deque<cmStdString> PreContext; + std::deque<std::string> PreContext; int TotalErrors; int TotalWarnings; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 17dbb55..ab363d0 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -99,7 +99,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -112,7 +112,7 @@ bool cmCTestCVS::UpdateImpl() cvs_update.push_back(this->CommandLineTool.c_str()); cvs_update.push_back("-z3"); cvs_update.push_back("update"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { cvs_update.push_back(ai->c_str()); @@ -308,7 +308,7 @@ bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml) " Gathering version information (one . per updated file):\n" " " << std::flush); - for(std::map<cmStdString, Directory>::const_iterator + for(std::map<std::string, Directory>::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h index b7fe567..64e1747 100644 --- a/Source/CTest/cmCTestCVS.h +++ b/Source/CTest/cmCTestCVS.h @@ -32,8 +32,8 @@ private: virtual bool WriteXMLUpdates(std::ostream& xml); // Update status for files in each directory. - class Directory: public std::map<cmStdString, PathStatus> {}; - std::map<cmStdString, Directory> Dirs; + class Directory: public std::map<std::string, PathStatus> {}; + std::map<std::string, Directory> Dirs; std::string ComputeBranchFlag(std::string const& dir); void LoadRevisions(std::string const& file, const char* branchFlag, diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 5eed409..1aa8768 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -69,7 +69,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmOStringStream e; e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return 0; } diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index b592c5a..7941d4e 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -38,7 +38,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_configure";} + virtual std::string GetName() const { return "ctest_configure";} cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 7c41298..a6e39a4 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -76,7 +76,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " - << cCommand.c_str() << std::endl); + << cCommand << std::endl); res = this->CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), 0, ofs); @@ -99,7 +99,7 @@ int cmCTestConfigureHandler::ProcessHandler() { os << retVal; } - os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>" + os << "<ConfigureCommand>" << cCommand << "</ConfigureCommand>" << std::endl; cmCTestLog(this->CTest, DEBUG, "End" << std::endl); os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl; diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 72ff720..41f016b 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -25,7 +25,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() { this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND"); - + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS"); cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>( this->CTest->GetInitializedHandler("coverage")); if ( !handler ) diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 11bb411..5762e07 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_coverage";} + virtual std::string GetName() const { return "ctest_coverage";} cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand); @@ -56,7 +56,7 @@ protected: }; bool LabelsMentioned; - std::set<cmStdString> Labels; + std::set<std::string> Labels; }; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 3c65c55..cb6e56e 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -157,7 +157,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log) logGlob += this->CTest->GetCurrentTag(); logGlob += "/CoverageLog*"; cmsys::Glob gl; - gl.FindFiles(logGlob.c_str()); + 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) @@ -241,7 +241,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); // Always check parent directory of the file. - std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(fFile); std::string checkDir; // We also need to check the binary/source directory pair. @@ -269,7 +269,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of " << file << std::endl); return false; } @@ -296,7 +296,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, checkDir = fSrcDir; } fFile = checkDir + "/" + relPath; - fFile = cmSystemTools::GetFilenamePath(fFile.c_str()); + fFile = cmSystemTools::GetFilenamePath(fFile); if ( fileDir == fFile ) { @@ -308,7 +308,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of: " << file << std::endl); return false; } @@ -363,7 +363,7 @@ int cmCTestCoverageHandler::ProcessHandler() // setup the regex exclude stuff this->CustomCoverageExcludeRegex.clear(); - std::vector<cmStdString>::iterator rexIt; + std::vector<std::string>::iterator rexIt; for ( rexIt = this->CustomCoverageExclude.begin(); rexIt != this->CustomCoverageExclude.end(); ++ rexIt ) @@ -383,6 +383,12 @@ int cmCTestCoverageHandler::ProcessHandler() { return error; } + file_count += this->HandleLCovCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } file_count += this->HandleTracePyCoverage(&cont); error = cont.Error; if ( file_count < 0 ) @@ -477,7 +483,7 @@ int cmCTestCoverageHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << fullFileName.c_str() + << fullFileName << std::endl); continue; } @@ -488,7 +494,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " - << fullFileName.c_str() << std::endl); + << fullFileName << std::endl); continue; } @@ -503,7 +509,7 @@ int cmCTestCoverageHandler::ProcessHandler() } const std::string fileName - = cmSystemTools::GetFilenameName(fullFileName.c_str()); + = cmSystemTools::GetFilenameName(fullFileName); std::string shortFileName = this->CTest->GetShortPathToFile(fullFileName.c_str()); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov @@ -516,7 +522,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullFileName.c_str(); + ostr << "Cannot open source file: " << fullFileName; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -535,7 +541,7 @@ int cmCTestCoverageHandler::ProcessHandler() cc != fcov.size() -1 ) { cmOStringStream ostr; - ostr << "Problem reading source file: " << fullFileName.c_str() + ostr << "Problem reading source file: " << fullFileName << " line:" << cc << " out total: " << fcov.size()-1; errorsWhileAccumulating.push_back(ostr.str()); error ++; @@ -605,7 +611,7 @@ int cmCTestCoverageHandler::ProcessHandler() if (!ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullPath.c_str(); + ostr << "Cannot open source file: " << fullPath; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -613,7 +619,7 @@ int cmCTestCoverageHandler::ProcessHandler() int untested = 0; std::string line; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Actually performing coverage for: " << i->c_str() << std::endl); + "Actually performing coverage for: " << *i << std::endl); while (cmSystemTools::GetLineFromStream(ifs, line)) { covLogFile << "\t\t<Line Number=\"" << untested << "\" Count=\"0\">" @@ -647,7 +653,7 @@ int cmCTestCoverageHandler::ProcessHandler() ++ erIt ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - " " << erIt->c_str() << std::endl); + " " << *erIt << std::endl); } } @@ -713,19 +719,19 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) this->CustomCoverageExclude); this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB", this->ExtraCoverageGlobs); - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->CustomCoverageExclude.begin(); it != this->CustomCoverageExclude.end(); ++ it ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " - << it->c_str() << std::endl); + << *it << std::endl); } for ( it = this->ExtraCoverageGlobs.begin(); it != this->ExtraCoverageGlobs.end(); ++it) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage glob: " - << it->c_str() << std::endl); + << *it << std::endl); } } @@ -871,9 +877,22 @@ int cmCTestCoverageHandler::HandleGCovCoverage( { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + if (gcovCommand.empty()) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Could not find gcov." << std::endl); + return 0; + } std::string gcovExtraFlags = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + // Immediately skip to next coverage option since codecov is only for Intel + // compiler + if ( gcovCommand == "codecov" ) + { + return 0; + } + // Style 1 std::string st1gcovOutputRex1 = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; @@ -941,7 +960,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // - std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(*it); std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " + "-o \"" + fileDir + "\" " + @@ -953,17 +972,17 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string output = ""; std::string errors = ""; int retVal = 0; - *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; - *cont->OFS << " Command: " << command.c_str() << std::endl; + *cont->OFS << "* Run coverage for: " << fileDir << std::endl; + *cont->OFS << " Command: " << command << std::endl; int res = this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal, tempDir.c_str(), 0 /*this->TimeOut*/); - *cont->OFS << " Output: " << output.c_str() << std::endl; - *cont->OFS << " Errors: " << errors.c_str() << std::endl; + *cont->OFS << " Output: " << output << std::endl; + *cont->OFS << " Errors: " << errors << std::endl; if ( ! res ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Problem running coverage on file: " << it->c_str() << std::endl); + "Problem running coverage on file: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); cont->Error ++; @@ -972,7 +991,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( retVal != 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " - << retVal << " while processing: " << it->c_str() << std::endl); + << retVal << " while processing: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << cont->Error << std::endl); } @@ -983,8 +1002,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( << "--------------------------------------------------------------" << std::endl); - std::vector<cmStdString> lines; - std::vector<cmStdString>::iterator line; + std::vector<std::string> lines; + std::vector<std::string>::iterator line; cmSystemTools::Split(output.c_str(), lines); @@ -993,7 +1012,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string sourceFile; std::string gcovFile; - cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]" + cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]" << std::endl); if ( line->size() == 0 ) @@ -1139,7 +1158,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Unknown gcov output line: [" << line->c_str() << "]" + "Unknown gcov output line: [" << *line << "]" << std::endl); cont->Error ++; //abort(); @@ -1232,8 +1251,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( IsFileInDir(sourceFile, cont->SourceDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in source dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in source dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1241,8 +1260,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( else if ( IsFileInDir(sourceFile, cont->BinaryDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in binary dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in binary dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1256,19 +1275,19 @@ int cmCTestCoverageHandler::HandleGCovCoverage( "Something went wrong" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Cannot find file: [" - << sourceFile.c_str() << "]" << std::endl); + << sourceFile << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in source dir: [" - << cont->SourceDir.c_str() << "]" + << cont->SourceDir << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " or binary dir: [" << cont->BinaryDir.size() << "]" << std::endl); *cont->OFS << " Something went wrong. Cannot find file: " - << sourceFile.c_str() - << " in source dir: " << cont->SourceDir.c_str() - << " or binary dir: " << cont->BinaryDir.c_str() << std::endl; + << sourceFile + << " in source dir: " << cont->SourceDir + << " or binary dir: " << cont->BinaryDir << std::endl; missingFiles.insert(sourceFile); } @@ -1290,6 +1309,270 @@ int cmCTestCoverageHandler::HandleGCovCoverage( return file_count; } +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleLCovCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + std::string lcovCommand + = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string lcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + if ( lcovCommand != "codecov" ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Not a valid Intel Coverage command." + << std::endl); + return 0; + } + // There is only percentage completed output from LCOV + std::string st2lcovOutputRex3 = "[0-9]+%"; + cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str()); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " This is coverage command: " << lcovCommand + << std::endl); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " These are coverage command flags: " << lcovExtraFlags + << std::endl); + + std::vector<std::string> files; + this->FindLCovFiles(files); + std::vector<std::string>::iterator it; + + if ( files.size() == 0 ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find any LCov coverage files." + << std::endl); + // No coverage files is a valid thing, so the exit code is 0 + return 0; + } + std::string testingDir = this->CTest->GetBinaryDir(); + std::string tempDir = testingDir; + std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); + + std::set<std::string> missingFiles; + + std::string actualSourceFile = ""; + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Processing coverage (each . represents one file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + int file_count = 0; + + // make sure output from lcov is in English! + cmCTestCoverageHandlerLocale locale_C; + static_cast<void>(locale_C); + + // 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 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); + std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + cmSystemTools::ChangeDirectory(fileDir.c_str()); + std::string command = "\"" + lcovCommand + "\" " + + lcovExtraFlags + " "; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: " + << fileDir.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() + << std::endl); + + std::string output = ""; + std::string errors = ""; + int retVal = 0; + *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; + *cont->OFS << " Command: " << command.c_str() << std::endl; + int res = this->CTest->RunCommand(command.c_str(), &output, &errors, + &retVal, fileDir.c_str(), 0 /*this->TimeOut*/); + + *cont->OFS << " Output: " << output.c_str() << std::endl; + *cont->OFS << " Errors: " << errors.c_str() << std::endl; + if ( ! res ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem running coverage on file: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << errors << std::endl); + cont->Error ++; + continue; + } + if ( retVal != 0 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " + << retVal << " while processing: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << cont->Error << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "--------------------------------------------------------------" + << std::endl + << output << std::endl + << "--------------------------------------------------------------" + << std::endl); + + 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) + { + std::string sourceFile; + std::string lcovFile; + + if ( line->size() == 0 ) + { + // Ignore empty line + } + // Look for LCOV files in binary directory + // Intel Compiler creates a CodeCoverage dir for each subfolder and + // each subfolder has LCOV files + cmsys::Glob gl; + gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); + std::string dir; + std::vector<std::string> lcovFiles; + dir = this->CTest->GetBinaryDir(); + std::string daGlob; + daGlob = dir; + daGlob += "/*.LCOV"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for LCOV files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + // Keep a list of all LCOV files + 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; + cmsys::ifstream srcead(lcovFile.c_str()); + if ( ! srcead ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + std::string srcname; + + int success = cmSystemTools::GetLineFromStream(srcead, srcname); + if ( !success ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while parsing lcov file '" << lcovFile << "':" + << " No source file name found!" << std::endl); + return 0; + } + srcname = srcname.substr(18); + // We can directly read found LCOV files to determine the source + // files + sourceFile = srcname; + actualSourceFile = srcname; + + for(std::vector<std::string>::iterator t = lcovFiles.begin(); + t != lcovFiles.end(); ++t) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found LCOV File: " + << *t << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: " + << sourceFile << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: " + << lcovFile << std::endl); + + // If we have some LCOV files to process + if ( !lcovFile.empty() && !actualSourceFile.empty() ) + { + cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec + = cont->TotalCoverage[actualSourceFile]; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in lcovFile: " + << lcovFile << std::endl); + + cmsys::ifstream ifile(lcovFile.c_str()); + if ( ! ifile ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + else + { + long cnt = -1; + std::string nl; + + // Skip the first line + cmSystemTools::GetLineFromStream(ifile, nl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "File is ready, start reading." << std::endl); + while ( cmSystemTools::GetLineFromStream(ifile, nl) ) + { + cnt ++; + + // Skip empty lines + if ( !nl.size() ) + { + continue; + } + + // Skip unused lines + if ( nl.size() < 12 ) + { + continue; + } + + // Read the coverage count from the beginning of the lcov + // output line + std::string prefix = nl.substr(0, 17); + int cov = atoi(prefix.c_str()); + + // Read the line number starting at the 17th character of the + // lcov output line + std::string lineNumber = nl.substr(17, 7); + + int lineIdx = atoi(lineNumber.c_str())-1; + if ( lineIdx >= 0 ) + { + while ( vec.size() <= static_cast<size_t>(lineIdx) ) + { + vec.push_back(-1); + } + + // Initially all entries are -1 (not used). If we get coverage + // information, increment it to 0 first. + if ( vec[lineIdx] < 0 ) + { + if ( cov > 0 || prefix.find("#") != prefix.npos ) + { + vec[lineIdx] = 0; + } + } + + vec[lineIdx] += cov; + } + } + } + + actualSourceFile = ""; + } + } + } + + file_count++; + + if ( file_count % 50 == 0 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count + << " out of " << files.size() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + } + } + + cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + return file_count; +} + //---------------------------------------------------------------------------- void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) { @@ -1321,6 +1604,34 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) } } +//---------------------------------------------------------------------------- +void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) +{ + cmsys::Glob gl; + gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is + // used while compiling. + gl.RecurseThroughSymlinksOff(); + std::string prevBinaryDir; + cmSystemTools::ChangeDirectory( + this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); + + // Run profmerge to merge all *.dyn files into dpi files + cmSystemTools::RunSingleCommand("profmerge"); + + prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); + + // DPI file should appear in build directory + std::string daGlob; + daGlob = prevBinaryDir; + daGlob += "/*.dpi"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for dpi files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Now searching in: " << daGlob << std::endl); +} + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleTracePyCoverage( cmCTestCoverageHandlerContainer* cont) @@ -1358,24 +1669,24 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find source Python file corresponding to: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); continue; } std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " Check coverage for file: " << actualSourceFile.c_str() + " Check coverage for file: " << actualSourceFile << std::endl); cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec = &cont->TotalCoverage[actualSourceFile]; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " in file: " << fileIt->c_str() << std::endl); + " in file: " << *fileIt << std::endl); cmsys::ifstream ifile(fileIt->c_str()); if ( ! ifile ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); } else { @@ -1423,7 +1734,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( // So, this will be set to 0. cov = 0; } - cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix.c_str() + cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix << " cov: " << cov << std::endl); // Read the line number starting at the 10th character of the gcov @@ -1498,7 +1809,7 @@ namespace //---------------------------------------------------------------------- int cmCTestCoverageHandler::RunBullseyeCoverageBranch( cmCTestCoverageHandlerContainer* cont, - std::set<cmStdString>& coveredFileNames, + std::set<std::string>& coveredFileNames, std::vector<std::string>& files, std::vector<std::string>& filesFullPath) { @@ -1536,10 +1847,10 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } - std::map<cmStdString, cmStdString> fileMap; + std::map<std::string, std::string> fileMap; std::vector<std::string>::iterator fp = filesFullPath.begin(); for(std::vector<std::string>::iterator f = files.begin(); f != files.end(); ++f, ++fp) @@ -1552,7 +1863,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( std::string lineIn; bool valid = false; // are we in a valid output file int line = 0; // line of the current file - cmStdString file; + std::string file; while(cmSystemTools::GetLineFromStream(fin, lineIn)) { bool startFile = false; @@ -1587,7 +1898,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( } count++; // move on one } - std::map<cmStdString, cmStdString>::iterator + std::map<std::string, std::string>::iterator i = fileMap.find(file); // if the file should be covered write out the header for that file if(i != fileMap.end()) @@ -1596,7 +1907,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( count++; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Produce coverage for file: " - << file.c_str() << " " << count + << file << " " << count << std::endl); // start the file output covLogFile << "\t<File Name=\"" @@ -1657,12 +1968,12 @@ int cmCTestCoverageHandler::RunBullseyeCommand( if(arg) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << " " << arg << "\n"); + "Run : " << program << " " << arg << "\n"); } else { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << "\n"); + "Run : " << program << "\n"); } // create a process object and start it cmCTestRunProcess runCoverageSrc; @@ -1680,7 +1991,7 @@ int cmCTestCoverageHandler::RunBullseyeCommand( if(!runCoverageSrc.StartProcess()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : " - << program.c_str() << " " << arg << "\n" + << program << " " << arg << "\n" << "kwsys process state : " << runCoverageSrc.GetProcessState()); return 0; @@ -1749,10 +2060,10 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } - std::set<cmStdString> coveredFileNames; + std::set<std::string> coveredFileNames; while(cmSystemTools::GetLineFromStream(fin, stdline)) { // if we have a line of output from stdout @@ -1790,14 +2101,14 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << file.c_str() + << file << std::endl); continue; } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Doing coverage for: " - << file.c_str() + << file << std::endl); coveredFiles.push_back(sourceFile); @@ -1808,7 +2119,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( total_tested += functionsCalled; total_untested += (totalFunctions - functionsCalled); - std::string fileName = cmSystemTools::GetFilenameName(file.c_str()); + std::string fileName = cmSystemTools::GetFilenameName(file); std::string shortFileName = this->CTest->GetShortPathToFile(file.c_str()); @@ -1824,7 +2135,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( cmet /= 2.0f; } cmet /= 100.0f; - tmpLog << stdline.c_str() << "\n"; + tmpLog << stdline << "\n"; tmpLog << fileName << "\n"; tmpLog << "functionsCalled: " << functionsCalled/100 << "\n"; tmpLog << "totalFunctions: " << totalFunctions/100 << "\n"; @@ -1951,7 +2262,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos == inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : " - << inputLine.c_str() << "\n"); + << inputLine << "\n"); return false; } // the source file has "" around it so extract out the file name @@ -1985,7 +2296,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos != inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : " - << inputLine.c_str() << " last pos not npos = " << pos << + << inputLine << " last pos not npos = " << pos << "\n"); } return true; @@ -2099,10 +2410,10 @@ void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os, //---------------------------------------------------------------------------- void -cmCTestCoverageHandler::SetLabelFilter(std::set<cmStdString> const& labels) +cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels) { this->LabelFilter.clear(); - for(std::set<cmStdString>::const_iterator li = labels.begin(); + for(std::set<std::string>::const_iterator li = labels.begin(); li != labels.end(); ++li) { this->LabelFilter.insert(this->GetLabelId(*li)); @@ -2152,7 +2463,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles( { std::set<std::string> extraMatches; - for(std::vector<cmStdString>::iterator i = this->ExtraCoverageGlobs.begin(); + for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin(); i != this->ExtraCoverageGlobs.end(); ++i) { cmsys::Glob gl; diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 660f501..0a0fe81 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -55,7 +55,7 @@ public: void PopulateCustomVectors(cmMakefile *mf); /** Report coverage only for sources with these labels. */ - void SetLabelFilter(std::set<cmStdString> const& labels); + void SetLabelFilter(std::set<std::string> const& labels); private: bool ShouldIDoCoverage(const char* file, const char* srcDir, @@ -68,6 +68,10 @@ private: int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont); void FindGCovFiles(std::vector<std::string>& files); + //! Handle coverage using Intel's LCov + int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); + void FindLCovFiles(std::vector<std::string>& files); + //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); @@ -81,7 +85,7 @@ private: int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont); int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont); int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont, - std::set<cmStdString>& coveredFileNames, + std::set<std::string>& coveredFileNames, std::vector<std::string>& files, std::vector<std::string>& filesFullPath); @@ -112,19 +116,19 @@ private: std::set<std::string> FindUncoveredFiles( cmCTestCoverageHandlerContainer* cont); - std::vector<cmStdString> CustomCoverageExclude; + std::vector<std::string> CustomCoverageExclude; std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex; - std::vector<cmStdString> ExtraCoverageGlobs; + std::vector<std::string> ExtraCoverageGlobs; // Map from source file to label ids. class LabelSet: public std::set<int> {}; - typedef std::map<cmStdString, LabelSet> LabelMapType; + typedef std::map<std::string, LabelSet> LabelMapType; LabelMapType SourceLabels; LabelMapType TargetDirs; // Map from label name to label id. - typedef std::map<cmStdString, int> LabelIdMapType; + typedef std::map<std::string, int> LabelIdMapType; LabelIdMapType LabelIdMap; std::vector<std::string> Labels; int GetLabelId(std::string const& label); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index abc33de..5ddef01 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx @@ -25,8 +25,8 @@ bool cmCTestEmptyBinaryDirectoryCommand if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) ) { cmOStringStream ostr; - ostr << "problem removing the binary directory: " << args[0].c_str(); - this->SetError(ostr.str().c_str()); + ostr << "problem removing the binary directory: " << args[0]; + this->SetError(ostr.str()); return false; } diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 07e59a4..d182d17 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_empty_binary_directory";} + virtual std::string GetName() const { return "ctest_empty_binary_directory";} cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 0e0e797..aaa01b2 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -179,8 +179,8 @@ bool cmCTestGIT::UpdateByFetchAndReset() { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + 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()); diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 5338f30..2df2229 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -30,12 +30,8 @@ cmCTestGenericHandler::~cmCTestGenericHandler() } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetOption(const char* op, const char* value) +void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -51,14 +47,10 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value) } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetPersistentOption(const char* op, +void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) { this->SetOption(op, value); - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -83,12 +75,12 @@ void cmCTestGenericHandler::Initialize() it != this->PersistentOptions.end(); ++ it ) { - this->Options[it->first.c_str()] = it->second.c_str(); + this->Options[it->first] = it->second.c_str(); } } //---------------------------------------------------------------------- -const char* cmCTestGenericHandler::GetOption(const char* op) +const char* cmCTestGenericHandler::GetOption(const std::string& op) { cmCTestGenericHandler::t_StringToString::iterator remit = this->Options.find(op); @@ -129,10 +121,10 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, return false; } if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), - ostr.str().c_str(), xofs, true) ) + ostr.str(), xofs, true) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create resulting XML file: " << ostr.str().c_str() + "Cannot create resulting XML file: " << ostr.str() << std::endl); return false; } @@ -161,10 +153,10 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, ostr << "_" << this->CTest->GetCurrentTag(); } ostr << ".log"; - if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) + if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " - << ostr.str().c_str() << std::endl); + << ostr.str() << std::endl); return false; } return true; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index ba8febb..2788cba 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -71,12 +71,12 @@ public: cmCTestGenericHandler(); virtual ~cmCTestGenericHandler(); - typedef std::map<cmStdString,cmStdString> t_StringToString; + typedef std::map<std::string,std::string> t_StringToString; - void SetPersistentOption(const char* op, const char* value); - void SetOption(const char* op, const char* value); - const char* GetOption(const char* op); + void SetPersistentOption(const std::string& op, const char* value); + void SetOption(const std::string& op, const char* value); + const char* GetOption(const std::string& op); void SetCommand(cmCTestCommand* command) { diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 8c51102..5f570b5 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -132,7 +132,7 @@ bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml) this->WriteXMLGlobal(xml); - for(std::map<cmStdString, Directory>::const_iterator + for(std::map<std::string, Directory>::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index a648a59..cb0d165 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -39,8 +39,8 @@ protected: }; // Update status for files in each directory. - class Directory: public std::map<cmStdString, File> {}; - std::map<cmStdString, Directory> Dirs; + class Directory: public std::map<std::string, File> {}; + std::map<std::string, Directory> Dirs; // Old and new repository revisions. std::string OldRevision; diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 86a7617..0f79d68 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -149,8 +149,8 @@ bool cmCTestHG::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + 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()); @@ -189,10 +189,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); if(const char* rev = this->FindAttribute(atts, "revision")) @@ -208,29 +208,29 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->HG->DoRevision(this->Rev, this->Changes); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if ( strcmp(name, "email") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "email") { this->Rev.EMail.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "files") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "files") { std::vector<std::string> paths = this->SplitCData(); for(unsigned int i = 0; i < paths.size(); ++i) @@ -242,7 +242,7 @@ private: this->Changes.push_back(this->CurChange); } } - else if(strcmp(name, "file_adds") == 0 && !this->CData.empty()) + 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) @@ -253,7 +253,7 @@ private: } } } - else if(strcmp(name, "file_dels") == 0 && !this->CData.empty()) + 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) diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 2e2feb0..0e29160 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -48,7 +48,7 @@ bool cmCTestHandlerCommand { cmOStringStream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index cd3bd57..10a5199 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -567,7 +567,7 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml) fxml << "\n"; fxml << "\t\t<!-- Interested parties -->\n"; fxml << "\t\t<Labels>\n"; - for(std::set<cmStdString>::const_iterator li = this->Labels.begin(); + for(std::set<std::string>::const_iterator li = this->Labels.begin(); li != this->Labels.end(); ++li) { fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n"; @@ -680,8 +680,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname) continue; } - if(this->Match(line.c_str(), this->RegexWarning) && - !this->Match(line.c_str(), this->RegexWarningSuppress)) + if(this->Match(line, this->RegexWarning) && + !this->Match(line, this->RegexWarningSuppress)) { return true; } diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index f680d19..bc90d28 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -73,7 +73,7 @@ private: bool HaveErr; // Labels associated with the build rule. - std::set<cmStdString> Labels; + std::set<std::string> Labels; void LoadLabels(); bool SourceMatches(std::string const& lhs, std::string const& rhs); diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index b50170d..e239d46 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_memcheck";} + virtual std::string GetName() const { return "ctest_memcheck";} cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index fdce04d..ecaa474 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -49,21 +49,15 @@ class cmBoundsCheckerParser : public cmXMLParser { public: cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;} - void StartElement(const char* name, const char** atts) + void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "MemoryLeak") == 0) + if(name == "MemoryLeak" || + name == "ResourceLeak") { this->Errors.push_back(cmCTestMemCheckHandler::MLK); } - if(strcmp(name, "ResourceLeak") == 0) - { - this->Errors.push_back(cmCTestMemCheckHandler::MLK); - } - if(strcmp(name, "Error") == 0) - { - this->ParseError(atts); - } - if(strcmp(name, "Dangling Pointer") == 0) + else if(name == "Error" || + name == "Dangling Pointer") { this->ParseError(atts); } @@ -79,7 +73,7 @@ public: ostr << "\n"; this->Log += ostr.str(); } - void EndElement(const char* ) + void EndElement(const std::string& ) { } @@ -246,8 +240,8 @@ int cmCTestMemCheckHandler::PostProcessHandler() void cmCTestMemCheckHandler::GenerateTestCommand( std::vector<std::string>& args, int test) { - std::vector<cmStdString>::size_type pp; - cmStdString index; + std::vector<std::string>::size_type pp; + std::string index; cmOStringStream stream; std::string memcheckcommand = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); @@ -255,9 +249,9 @@ void cmCTestMemCheckHandler::GenerateTestCommand( index = stream.str(); for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ ) { - cmStdString arg = this->MemoryTesterDynamicOptions[pp]; - cmStdString::size_type pos = arg.find("??"); - if (pos != cmStdString::npos) + std::string arg = this->MemoryTesterDynamicOptions[pp]; + std::string::size_type pos = arg.find("??"); + if (pos != std::string::npos) { arg.replace(pos, 2, index); } @@ -520,7 +514,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find memory checker suppression file: " << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); + "MemoryCheckSuppressionFile") << std::endl); return false; } std::string suppressions = "--suppressions=" @@ -575,12 +569,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } default: cmCTestLog(this->CTest, ERROR_MESSAGE, - "Do not understand memory checker: " << this->MemoryTester.c_str() + "Do not understand memory checker: " << this->MemoryTester << std::endl); return false; } - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { this->MemoryTesterGlobalResults[cc] = 0; @@ -627,7 +621,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( const std::string& str, std::string& log, int* results) { - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); cmOStringStream ostr; log = ""; @@ -636,7 +630,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( int defects = 0; - for( std::vector<cmStdString>::iterator i = lines.begin(); + for( std::vector<std::string>::iterator i = lines.begin(); i != lines.end(); ++i) { int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; @@ -681,7 +675,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( const std::string& str, std::string& log, int* results) { - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); bool unlimitedOutput = false; if(str.find("CTEST_FULL_OUTPUT") != str.npos || @@ -864,10 +858,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( { log = ""; double sttime = cmSystemTools::GetTime(); - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl); - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cc < lines.size(); cc ++ ) { if(lines[cc] == BOUNDS_CHECKER_MARKER) @@ -891,7 +885,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( else if(!parser.ParseChunk(theLine.c_str(), theLine.size())) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Error in ParseChunk: " << theLine.c_str() + "Error in ParseChunk: " << theLine << std::endl); } } @@ -922,8 +916,8 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " - << res.Name.c_str() << std::endl); - cmStdString ofile = testOutputFileName(test); + << res.Name << std::endl); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { return; @@ -949,10 +943,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, cmSystemTools::Delay(1000); cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerDPBDFile.c_str() << std::endl); + << this->BoundsCheckerDPBDFile << std::endl); cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerXMLFile.c_str() << std::endl); + << this->BoundsCheckerXMLFile << std::endl); } void @@ -961,7 +955,7 @@ cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } @@ -971,7 +965,7 @@ cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessValgrindTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } @@ -979,7 +973,7 @@ void cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, int test) { - cmStdString ofile = testOutputFileName(test); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { @@ -1000,15 +994,15 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, } } -cmStdString +std::string cmCTestMemCheckHandler::testOutputFileName(int test) { - cmStdString index; + std::string index; cmOStringStream stream; stream << test; index = stream.str(); - cmStdString ofile = this->MemoryTesterOutputFile; - cmStdString::size_type pos = ofile.find("??"); + std::string ofile = this->MemoryTesterOutputFile; + std::string::size_type pos = ofile.find("??"); ofile.replace(pos, 2, index); if ( !cmSystemTools::FileExists(ofile.c_str()) ) diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 040d2e0..0521a48 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -89,8 +89,8 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; - std::vector<cmStdString> MemoryTesterDynamicOptions; - std::vector<cmStdString> MemoryTesterOptions; + std::vector<std::string> MemoryTesterDynamicOptions; + std::vector<std::string> MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; @@ -103,8 +103,8 @@ private: */ void GenerateDartOutput(std::ostream& os); - std::vector<cmStdString> CustomPreMemCheck; - std::vector<cmStdString> CustomPostMemCheck; + std::vector<std::string> CustomPreMemCheck; + std::vector<std::string> CustomPostMemCheck; //! Parse Valgrind/Purify/Bounds Checker result out of the output //string. After running, log holds the output and results hold the @@ -127,7 +127,7 @@ private: int test); ///! generate the output filename for the given test index - cmStdString testOutputFileName(int test); + std::string testOutputFileName(int test); }; #endif diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index ddd1707..b9e6721 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -369,7 +369,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() // Write list of failed tests fout << "---\n"; - for(std::vector<cmStdString>::iterator i = this->Failed->begin(); + for(std::vector<std::string>::iterator i = this->Failed->begin(); i != this->Failed->end(); ++i) { fout << i->c_str() << "\n"; @@ -672,7 +672,7 @@ void cmCTestMultiProcessHandler::PrintTestList() indexStr << " #" << p.Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl); //pop working dir diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 1b53ec7..605de31 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -41,8 +41,8 @@ public: void PrintTestList(); void PrintLabels(); - void SetPassFailVectors(std::vector<cmStdString>* passed, - std::vector<cmStdString>* failed) + void SetPassFailVectors(std::vector<std::string>* passed, + std::vector<std::string>* failed) { this->Passed = passed; this->Failed = failed; @@ -107,9 +107,9 @@ protected: PropertiesMap Properties; std::map<int, bool> TestRunningMap; std::map<int, bool> TestFinishMap; - std::map<int, cmStdString> TestOutput; - std::vector<cmStdString>* Passed; - std::vector<cmStdString>* Failed; + std::map<int, std::string> TestOutput; + std::vector<std::string>* Passed; + std::vector<std::string>* Failed; std::vector<std::string> LastTestsFailed; std::set<std::string> LockedResources; std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index b09d6f5..0bb1a99 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -346,13 +346,13 @@ void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions) //The CTEST_P4_OPTIONS variable adds additional Perforce command line //options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector<cmStdString> args = + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { - P4Options.push_back(ai->c_str()); + P4Options.push_back(*ai); } } @@ -538,8 +538,8 @@ bool cmCTestP4::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + 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()); diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index 9c0af81..c95694a 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_read_custom_files";} + virtual std::string GetName() const { return "ctest_read_custom_files";} cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index fe429bd..bdf9b9c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -56,7 +56,7 @@ bool cmCTestRunScriptCommand &ret); cmOStringStream str; str << ret; - this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str()); + this->Makefile->AddDefinition(returnVariable, str.str().c_str()); } } return true; diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index f34bd13..0998e5c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_run_script";} + virtual std::string GetName() const { return "ctest_run_script";} cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index cdf90b9..385388d 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -334,9 +334,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) *this->TestHandler->LogFile << "Test Failed.\n"; } } - *this->TestHandler->LogFile << "\"" << this->TestProperties->Name.c_str() + *this->TestHandler->LogFile << "\"" << this->TestProperties->Name << "\" end time: " << this->CTest->CurrentTime() << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" time elapsed: " + << "\"" << this->TestProperties->Name << "\" time elapsed: " << buffer << std::endl << "----------------------------------------------------------" << std::endl << std::endl; @@ -388,8 +388,8 @@ void cmCTestRunTest::MemCheckPostProcess() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": process test output now: " - << this->TestProperties->Name.c_str() << " " - << this->TestResult.Name.c_str() << std::endl); + << this->TestProperties->Name << " " + << this->TestResult.Name << std::endl); cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*> (this->TestHandler); switch ( handler->MemoryTesterStyle ) @@ -465,9 +465,9 @@ bool cmCTestRunTest::StartTest(size_t total) //Required file was not found this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find required file: " - << file.c_str() << std::endl; + << file << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: " - << file.c_str() << std::endl); + << file << std::endl); this->TestResult.Output = "Unable to find required file: " + file; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -482,9 +482,9 @@ bool cmCTestRunTest::StartTest(size_t total) // that has that information this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find executable: " - << args[1].c_str() << std::endl; + << args[1] << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " - << args[1].c_str() << std::endl); + << args[1] << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -711,7 +711,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) indexStr << " #" << this->Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth(); std::string outname = this->TestProperties->Name + " "; @@ -722,18 +722,18 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << this->TestProperties->Name << std::endl; *this->TestHandler->LogFile << this->TestProperties->Index << "/" << this->TestHandler->TotalNumberOfTests - << " Test: " << this->TestProperties->Name.c_str() << std::endl; + << " Test: " << this->TestProperties->Name << 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->c_str() << "\""; + << " \"" << *i << "\""; } *this->TestHandler->LogFile << std::endl << "Directory: " << this->TestProperties->Directory << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" start time: " + << "\"" << this->TestProperties->Name << "\" start time: " << this->StartTime << std::endl; *this->TestHandler->LogFile @@ -741,9 +741,9 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << "----------------------------------------------------------" << std::endl; *this->TestHandler->LogFile - << this->ProcessOutput.c_str() << "<end of output>" << std::endl; + << this->ProcessOutput << "<end of output>" << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str()); cmCTestLog(this->CTest, DEBUG, "Testing " - << this->TestProperties->Name.c_str() << " ... "); + << this->TestProperties->Name << " ... "); } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 2668c8e..86dc2f2 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -277,7 +277,7 @@ bool cmCTestSVN::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -287,7 +287,7 @@ bool cmCTestSVN::UpdateImpl() std::vector<char const*> svn_update; svn_update.push_back("update"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { svn_update.push_back(ai->c_str()); @@ -314,9 +314,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); - std::vector<cmStdString> parsedUserOptions = + std::vector<std::string> parsedUserOptions = cmSystemTools::ParseArguments(userOptions.c_str()); - for(std::vector<cmStdString>::iterator i = parsedUserOptions.begin(); + for(std::vector<std::string>::iterator i = parsedUserOptions.begin(); i != parsedUserOptions.end(); ++i) { args.push_back(i->c_str()); @@ -361,10 +361,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); this->Rev.SVNInfo = &SVNRepo; @@ -374,7 +374,7 @@ private: } this->Changes.clear(); } - else if(strcmp(name, "path") == 0) + else if(name == "path") { this->CurChange = Change(); if(const char* action = this->FindAttribute(atts, "action")) @@ -389,28 +389,28 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->SVN->DoRevisionSVN(this->Rev, this->Changes); } - else if(strcmp(name, "path") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "path") { std::string orig_path(&this->CData[0], this->CData.size()); std::string new_path = SVNRepo.BuildLocalPath( orig_path ); this->CurChange.Path.assign(new_path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 00a0a09..567acfc 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -231,7 +231,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments - std::vector<cmStdString> &initArgs = + std::vector<std::string> &initArgs = this->CTest->GetInitialCommandLineArguments(); //*** need to make sure this does not have the current script *** for(size_t i=1; i < initArgs.size(); ++i) @@ -337,8 +337,8 @@ void cmCTestScriptHandler::CreateCMake() // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. // Also, some commands need Makefile->GetCurrentDirectory(). std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->Makefile->SetStartDirectory(cwd.c_str()); - this->Makefile->SetStartOutputDirectory(cwd.c_str()); + this->Makefile->SetStartDirectory(cwd); + this->Makefile->SetStartOutputDirectory(cwd); // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts @@ -426,7 +426,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" - << systemFile.c_str() << "\n"); + << systemFile << "\n"); return 2; } @@ -436,7 +436,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) for (std::map<std::string, std::string>::const_iterator it = defs.begin(); it != defs.end(); ++it) { - this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str()); + this->Makefile->AddDefinition(it->first, it->second.c_str()); } // finally read in the script @@ -444,7 +444,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: " - << script.c_str() + << script << std::endl); // Reset the error flag so that it can run more than // one script with an error when you @@ -646,7 +646,7 @@ int cmCTestScriptHandler::RunCurrentScript() if (!this->CTestEnv.empty()) { std::vector<std::string> envArgs; - cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs); + cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs); cmSystemTools::AppendEnv(envArgs); } @@ -766,13 +766,13 @@ int cmCTestScriptHandler::PerformExtraUpdates() // do an initial cvs update as required command = this->UpdateCmd; - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++ it ) { std::vector<std::string> cvsArgs; - cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs); + cmSystemTools::ExpandListArgument(*it,cvsArgs); if (cvsArgs.size() == 2) { std::string fullCommand = command; @@ -781,7 +781,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " - << fullCommand.c_str() << std::endl); + << fullCommand << std::endl); res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -902,7 +902,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() command += "\""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -916,7 +916,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Write CMake output to file: " << cmakeOutputFile.c_str() + "Write CMake output to file: " << cmakeOutputFile << std::endl); cmGeneratedFileStream fout(cmakeOutputFile.c_str()); if ( fout ) @@ -927,7 +927,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open CMake output file: " - << cmakeOutputFile.c_str() << " for writing" << std::endl); + << cmakeOutputFile << " for writing" << std::endl); } } if (!res || retVal != 0) @@ -948,7 +948,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -962,13 +962,13 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run cmake:" << std::endl - << cmakeFailedOuput.c_str() << std::endl); + << cmakeFailedOuput << std::endl); return 10; } cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run ctest:" << std::endl - << "command: " << command.c_str() << std::endl - << "output: " << output.c_str() << std::endl); + << "command: " << command << std::endl + << "output: " << output << std::endl); if (!res) { return 11; diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 44e9dd0..42c2f20 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -138,26 +138,26 @@ private: // Try to remove the binary directory once static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath); - std::vector<cmStdString> ConfigurationScripts; + std::vector<std::string> ConfigurationScripts; std::vector<bool> ScriptProcessScope; bool Backup; bool EmptyBinDir; bool EmptyBinDirOnce; - cmStdString SourceDir; - cmStdString BinaryDir; - cmStdString BackupSourceDir; - cmStdString BackupBinaryDir; - cmStdString CTestRoot; - cmStdString CVSCheckOut; - cmStdString CTestCmd; - cmStdString UpdateCmd; - cmStdString CTestEnv; - cmStdString InitialCache; - cmStdString CMakeCmd; - cmStdString CMOutFile; - std::vector<cmStdString> ExtraUpdates; + std::string SourceDir; + std::string BinaryDir; + std::string BackupSourceDir; + std::string BackupBinaryDir; + std::string CTestRoot; + std::string CVSCheckOut; + std::string CTestCmd; + std::string UpdateCmd; + std::string CTestEnv; + std::string InitialCache; + std::string CMakeCmd; + std::string CMOutFile; + std::vector<std::string> ExtraUpdates; double MinimumInterval; double ContinuousDuration; diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index c6baf1c..740a7e1 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_sleep";} + virtual std::string GetName() const { return "ctest_sleep";} cmTypeMacro(cmCTestSleepCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 228a173..da46f4a 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -131,7 +131,7 @@ bool cmCTestStartCommand << " " << sourceDir << "\n" << "which is not an existing directory. " << "Set CTEST_CHECKOUT_COMMAND to a command line to create it."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -160,7 +160,7 @@ bool cmCTestStartCommand::InitialCheckout( { // Use a generic VC object to run and log the command. cmCTestVC vc(this->CTest, ofs); - vc.SetSourceDirectory(sourceDir.c_str()); + vc.SetSourceDirectory(sourceDir); if(!vc.InitialCheckout(initialCheckoutCommand)) { return false; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index e5535c1..3b8843f 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -55,7 +55,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_start";} + virtual std::string GetName() const { return "ctest_start";} cmTypeMacro(cmCTestStartCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 24974e3..07a994d 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -72,7 +72,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (notesFilesVariable) { std::vector<std::string> notesFiles; - std::vector<cmStdString> newNotesFiles; + cmCTest::VectorOfStrings newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); std::vector<std::string>::iterator it; for ( it = notesFiles.begin(); @@ -89,7 +89,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (extraFilesVariable) { std::vector<std::string> extraFiles; - std::vector<cmStdString> newExtraFiles; + cmCTest::VectorOfStrings newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); std::vector<std::string>::iterator it; for ( it = extraFiles.begin(); @@ -222,7 +222,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 64c6cae..3673fbd 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_submit";} + virtual std::string GetName() const { return "ctest_submit";} cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 139f515..7c72cba 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -68,10 +68,10 @@ private: return val; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CurrentValue.clear(); - if(strcmp(name, "cdash") == 0) + if(name == "cdash") { this->CDashVersion = this->FindAttribute(atts, "version"); } @@ -82,9 +82,9 @@ private: this->CurrentValue.insert(this->CurrentValue.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "status") == 0) + if(name == "status") { std::string status = cmSystemTools::UpperCase(this->GetCurrentValue()); if(status == "OK" || status == "SUCCESS") @@ -100,15 +100,15 @@ private: this->Status = STATUS_ERROR; } } - else if(strcmp(name, "filename") == 0) + else if(name == "filename") { this->Filename = this->GetCurrentValue(); } - else if(strcmp(name, "md5") == 0) + else if(name == "md5") { this->MD5 = this->GetCurrentValue(); } - else if(strcmp(name, "message") == 0) + else if(name == "message") { this->Message = this->GetCurrentValue(); } @@ -170,10 +170,10 @@ void cmCTestSubmitHandler::Initialize() } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -217,30 +217,30 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString upload_as + std::string upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); struct stat st; if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; } ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << upload_as.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << upload_as << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << std::endl); + << local_file << " to " + << upload_as << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -290,11 +290,11 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl @@ -324,10 +324,10 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, //---------------------------------------------------------------------------- // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -336,10 +336,10 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); - cmStdString curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector<std::string> args; - cmSystemTools::ExpandListArgument(curlopt.c_str(), args); + cmSystemTools::ExpandListArgument(curlopt, args); bool verifyPeerOff = false; bool verifyHostOff = false; for( std::vector<std::string>::iterator i = args.begin(); @@ -354,7 +354,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, verifyHostOff = true; } } - cmStdString::size_type kk; + std::string::size_type kk; cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { @@ -414,18 +414,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString remote_file + std::string remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << remote_file.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << remote_file << std::endl; - cmStdString ofile = ""; + std::string ofile = ""; for ( kk = 0; kk < remote_file.size(); kk ++ ) { char c = remote_file[kk]; @@ -448,8 +448,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ofile.append(hexCh); } } - cmStdString upload_as - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string upload_as + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "FileName=" + ofile; upload_as += "&MD5="; @@ -461,7 +461,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, else { char md5[33]; - cmSystemTools::ComputeFileMD5(local_file.c_str(), md5); + cmSystemTools::ComputeFileMD5(local_file, md5); md5[32] = 0; upload_as += md5; } @@ -470,7 +470,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; @@ -478,8 +478,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << " Size: " << st.st_size << std::endl); + << local_file << " to " + << upload_as << " Size: " << st.st_size << std::endl); // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -595,11 +595,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl; @@ -666,9 +666,9 @@ void cmCTestSubmitHandler //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::TriggerUsingHTTP( - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; char error_buffer[1024]; @@ -721,10 +721,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - cmStdString rfile + std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); - cmStdString ofile = ""; - cmStdString::iterator kk; + std::string ofile = ""; + std::string::iterator kk; for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) { char c = *kk; @@ -747,18 +747,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ofile.append(hexCh); } } - cmStdString turl - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string turl + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "xmlfile=" + ofile; - *this->LogFile << "Trigger url: " << turl.c_str() << std::endl; + *this->LogFile << "Trigger url: " << turl << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " - << turl.c_str() << std::endl); + << turl << std::endl); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: " - << turl.c_str() << std::endl); + << turl << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << "\tTriggering failed with error: " << error_buffer @@ -805,11 +805,11 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingSCP( - const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::string& scp_command, + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { if ( !scp_command.size() || !localprefix.size() || !files.size() || !remoteprefix.size() || !url.size() ) @@ -906,10 +906,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingCP( - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& destination) + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& destination) { if ( !localprefix.size() || !files.size() || !remoteprefix.size() || !destination.size() ) @@ -932,8 +932,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP( std::string rfname = destination + "/" + remoteprefix + *file; cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: " - << lfname.c_str() << " to " - << rfname.c_str() << std::endl); + << lfname << " to " + << rfname << std::endl); } std::string tagDoneFile = destination + "/" + remoteprefix + "DONE"; cmSystemTools::Touch(tagDoneFile.c_str(), true); @@ -947,17 +947,17 @@ bool cmCTestSubmitHandler::SubmitUsingCP( //---------------------------------------------------------------------------- #if defined(CTEST_USE_XMLRPC) -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { xmlrpc_env env; char ctestString[] = "CTest"; std::string ctestVersionString = cmVersion::GetCMakeVersion(); char* ctestVersion = const_cast<char*>(ctestVersionString.c_str()); - cmStdString realURL = url + "/" + remoteprefix + "/Command/"; + std::string realURL = url + "/" + remoteprefix + "/Command/"; /* Start up our XML-RPC client library. */ xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion); @@ -973,7 +973,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, { xmlrpc_value *result; - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; @@ -1045,10 +1045,10 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, return true; } #else -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(cmStdString const&, - std::set<cmStdString> const&, - cmStdString const&, - cmStdString const&) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&, + std::set<std::string> const&, + std::string const&, + std::string const&) { return false; } @@ -1085,7 +1085,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("HTTP_PROXY_TYPE") ) { - cmStdString type = getenv("HTTP_PROXY_TYPE"); + std::string type = getenv("HTTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1122,7 +1122,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("FTP_PROXY_TYPE") ) { - cmStdString type = getenv("FTP_PROXY_TYPE"); + std::string type = getenv("FTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1178,12 +1178,12 @@ int cmCTestSubmitHandler::ProcessHandler() this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml"); if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) { - cmCTest::VectorOfStrings gfiles; + std::vector<std::string> gfiles; std::string gpath = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag(); std::string::size_type glen = gpath.size() + 1; gpath = gpath + "/CoverageLog*"; - cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str() + cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath << std::endl); if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) ) { @@ -1191,7 +1191,7 @@ int cmCTestSubmitHandler::ProcessHandler() for ( cc = 0; cc < gfiles.size(); cc ++ ) { gfiles[cc] = gfiles[cc].substr(glen); - cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() + cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc] << std::endl); this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str()); } @@ -1232,7 +1232,7 @@ int cmCTestSubmitHandler::ProcessHandler() cmCTest::SetOfStrings::iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - ofs << cnt << "\t" << it->c_str() << std::endl; + ofs << cnt << "\t" << *it << std::endl; cnt ++; } } @@ -1247,7 +1247,7 @@ int cmCTestSubmitHandler::ProcessHandler() } this->SetLogFile(&ofs); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); if ( dropMethod == "" || dropMethod == "ftp" ) { @@ -1448,7 +1448,7 @@ int cmCTestSubmitHandler::ProcessHandler() oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(buildDirectory.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " - << buildDirectory.c_str() << std::endl); + << buildDirectory << std::endl); if ( !this->SubmitUsingCP( "Testing/"+this->CTest->GetCurrentTag(), diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 14eac80..accabd1 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -47,33 +47,33 @@ private: /** * Submit file using various ways */ - bool SubmitUsingFTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingHTTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingSCP(const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingCP( const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool TriggerUsingHTTP(const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); + bool SubmitUsingFTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingHTTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingSCP(const std::string& scp_command, + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingCP( const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool TriggerUsingHTTP(const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingXMLRPC(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar; @@ -82,10 +82,10 @@ private: std::string GetSubmitResultsPrefix(); class ResponseParser; - cmStdString HTTPProxy; + std::string HTTPProxy; int HTTPProxyType; - cmStdString HTTPProxyAuth; - cmStdString FTPProxy; + std::string HTTPProxyAuth; + std::string FTPProxy; int FTPProxyType; std::ostream* LogFile; bool SubmitPart[cmCTest::PartCount]; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 451ac99..a1e5f36 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_test";} + virtual std::string GetName() const { return "ctest_test";} cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3a04b33..1d1dde4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -60,7 +60,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "subdirs";} + virtual std::string GetName() const { return "subdirs";} cmTypeMacro(cmCTestSubdirCommand, cmCommand); @@ -125,7 +125,7 @@ bool cmCTestSubdirCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } } @@ -157,7 +157,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_subdirectory";} + virtual std::string GetName() const { return "add_subdirectory";} cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand); @@ -213,7 +213,7 @@ bool cmCTestAddSubdirectoryCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } return true; @@ -243,7 +243,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_test";} + virtual std::string GetName() const { return "add_test";} cmTypeMacro(cmCTestAddTestCommand, cmCommand); @@ -287,7 +287,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_tests_properties";} + virtual std::string GetName() const { return "set_tests_properties";} cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); @@ -540,8 +540,8 @@ int cmCTestTestHandler::ProcessHandler() this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile); this->LogFile = &mLogFile; - std::vector<cmStdString> passed; - std::vector<cmStdString> failed; + std::vector<std::string> passed; + std::vector<std::string> failed; int total; //start the real time clock @@ -569,7 +569,7 @@ int cmCTestTestHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl << "The following tests passed:" << std::endl); - for(std::vector<cmStdString>::iterator j = passed.begin(); + for(std::vector<std::string>::iterator j = passed.begin(); j != passed.end(); ++j) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j @@ -616,7 +616,7 @@ int cmCTestTestHandler::ProcessHandler() ofs << ftit->TestCount << ":" << ftit->Name << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3) << ftit->TestCount << " - " - << ftit->Name.c_str() << " (" + << ftit->Name << " (" << this->GetTestStatus(ftit->Status) << ")" << std::endl); } @@ -661,8 +661,8 @@ void cmCTestTestHandler::PrintLabelSummary() cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); cmCTestTestHandler::TestResultsVector::iterator ri = this->TestResults.begin(); - std::map<cmStdString, double> labelTimes; - std::set<cmStdString> labels; + std::map<std::string, double> labelTimes; + std::set<std::string> labels; // initialize maps std::string::size_type maxlen = 0; for(; it != this->TestList.end(); ++it) @@ -702,7 +702,7 @@ void cmCTestTestHandler::PrintLabelSummary() { cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:"); } - for(std::set<cmStdString>::const_iterator i = labels.begin(); + for(std::set<std::string>::const_iterator i = labels.begin(); i != labels.end(); ++i) { std::string label = *i; @@ -1022,7 +1022,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, { cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: " - << tag << " found [" << line.c_str() << "]" << std::endl); + << tag << " found [" << line << "]" << std::endl); ret = false; } return ret; @@ -1050,8 +1050,8 @@ bool cmCTestTestHandler::GetValue(const char* tag, } //--------------------------------------------------------------------- -void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, - std::vector<cmStdString> &failed) +void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed, + std::vector<std::string> &failed) { this->ComputeTestList(); this->StartTest = this->CTest->CurrentTime(); @@ -1216,14 +1216,14 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << "name=\"Command Line\"><Value>" << cmXMLSafe(result->FullCommandLine) << "</Value></NamedMeasurement>\n"; - std::map<cmStdString,cmStdString>::iterator measureIt; + std::map<std::string,std::string>::iterator measureIt; for ( measureIt = result->Properties->Measurements.begin(); measureIt != result->Properties->Measurements.end(); ++ measureIt ) { os << "\t\t\t<NamedMeasurement type=\"text/string\" " - << "name=\"" << measureIt->first.c_str() << "\"><Value>" + << "name=\"" << measureIt->first << "\"><Value>" << cmXMLSafe(measureIt->second) << "</Value></NamedMeasurement>\n"; } @@ -1328,9 +1328,9 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os, } //---------------------------------------------------------------------- -int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) +int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; @@ -1506,7 +1506,7 @@ std::string cmCTestTestHandler // then try with the exe extension else { - failed.push_back(attempted[ai].c_str()); + failed.push_back(attempted[ai]); tempPath = attempted[ai]; tempPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tempPath.c_str()) @@ -1517,7 +1517,7 @@ std::string cmCTestTestHandler } else { - failed.push_back(tempPath.c_str()); + failed.push_back(tempPath); } } } @@ -1820,7 +1820,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: " - << lastTestsFailedLog.c_str() << + << lastTestsFailedLog << " while generating list of previously failed tests." << std::endl); } } @@ -1960,7 +1960,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << " " << k1 << "=\"" << v1 << "\"" << " " << k2 << "=\"" << v2 << "\"" << " encoding=\"none\"" - << "><Value>Image " << filename.c_str() + << "><Value>Image " << filename << " is empty</Value></NamedMeasurement>"; } else @@ -2014,10 +2014,10 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << "\t\t\t<NamedMeasurement" << " name=\"" << measurementfile.match(idx) << "\"" << " text=\"text/string\"" - << "><Value>File " << filename.c_str() + << "><Value>File " << filename << " not found</Value></NamedMeasurement>" << std::endl; - cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() + cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename << "\" not found." << std::endl); } cxml.erase(measurementfile.start(), @@ -2112,7 +2112,7 @@ bool cmCTestTestHandler::SetTestsProperties( const std::vector<std::string>& args) { std::vector<std::string>::const_iterator it; - std::vector<cmStdString> tests; + std::vector<std::string> tests; bool found = false; for ( it = args.begin(); it != args.end(); ++ it ) { @@ -2137,7 +2137,7 @@ bool cmCTestTestHandler::SetTestsProperties( break; } std::string val = *it; - std::vector<cmStdString>::const_iterator tit; + std::vector<std::string>::const_iterator tit; for ( tit = tests.begin(); tit != tests.end(); ++ tit ) { cmCTestTestHandler::ListOfTests::iterator rtit; @@ -2154,7 +2154,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2165,7 +2165,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES_ON_FAIL" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2176,7 +2176,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "RESOURCE_LOCK" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2196,7 +2196,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "REQUIRED_FILES" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2211,14 +2211,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "FAIL_REGULAR_EXPRESSION" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->ErrorRegularExpressions.push_back( std::pair<cmsys::RegularExpression, std::string>( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "PROCESSORS" ) @@ -2240,7 +2240,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "DEPENDS" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2250,7 +2250,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ENVIRONMENT" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2260,7 +2260,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "LABELS" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2284,14 +2284,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "PASS_REGULAR_EXPRESSION" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->RequiredRegularExpressions.push_back( std::pair<cmsys::RegularExpression, std::string>( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "WORKING_DIRECTORY" ) @@ -2319,7 +2319,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) } if ( this->MemCheck ) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) @@ -2339,7 +2339,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) } else { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 63f9c93..fe43bb8 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -87,8 +87,8 @@ public: // ctest -j N will break for that feature struct cmCTestTestProperties { - cmStdString Name; - cmStdString Directory; + std::string Name; + std::string Directory; std::vector<std::string> Args; std::vector<std::string> RequiredFiles; std::vector<std::string> Depends; @@ -98,7 +98,7 @@ public: std::string> > ErrorRegularExpressions; std::vector<std::pair<cmsys::RegularExpression, std::string> > RequiredRegularExpressions; - std::map<cmStdString, cmStdString> Measurements; + std::map<std::string, std::string> Measurements; bool IsInBasedOnREOptions; bool WillFail; float Cost; @@ -162,7 +162,7 @@ protected: virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector<std::string>& args, int test); - int ExecuteCommands(std::vector<cmStdString>& vec); + int ExecuteCommands(std::vector<std::string>& vec); void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); @@ -177,7 +177,7 @@ protected: typedef std::vector<cmCTestTestResult> TestResultsVector; TestResultsVector TestResults; - std::vector<cmStdString> CustomTestsIgnore; + std::vector<std::string> CustomTestsIgnore; std::string StartTest; std::string EndTest; unsigned int StartTestTime; @@ -210,8 +210,8 @@ private: /** * Run the tests for a directory and any subdirectories */ - void ProcessDirectory(std::vector<cmStdString> &passed, - std::vector<cmStdString> &failed); + void ProcessDirectory(std::vector<std::string> &passed, + std::vector<std::string> &failed); /** * Get the list of tests in directory and subdirectories. @@ -251,8 +251,8 @@ private: void ExpandTestsToRunInformation(size_t numPossibleTests); void ExpandTestsToRunInformationForRerunFailed(); - std::vector<cmStdString> CustomPreTest; - std::vector<cmStdString> CustomPostTest; + std::vector<std::string> CustomPreTest; + std::vector<std::string> CustomPostTest; std::vector<int> TestsToRun; diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index a785bd8..fb80333 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_update";} + virtual std::string GetName() const { return "ctest_update";} cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 11474ec..fda61ea 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -331,7 +331,7 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir) { std::string sourceDirectory = dir; cmCTestLog(this->CTest, DEBUG, "Check directory: " - << sourceDirectory.c_str() << std::endl); + << sourceDirectory << std::endl); sourceDirectory += "/.svn"; if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) { diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 731c1c7..f7de294 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -47,7 +47,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg) { if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index e867fb6..4a07608 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_upload";} + virtual std::string GetName() const { return "ctest_upload";} cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx index caf2e53..4c3f81b 100644 --- a/Source/CTest/cmCTestUploadHandler.cxx +++ b/Source/CTest/cmCTestUploadHandler.cxx @@ -64,7 +64,7 @@ int cmCTestUploadHandler::ProcessHandler() for ( it = this->Files.begin(); it != this->Files.end(); it ++ ) { cmCTestLog(this->CTest, OUTPUT, - "\tUpload file: " << it->c_str() << std::endl); + "\tUpload file: " << *it << std::endl); ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n" << "<Content encoding=\"base64\">\n"; ofs << this->CTest->Base64EncodeFile(*it); diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index fbee227..f89fa2b 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -63,9 +63,9 @@ bool cmCTestVC::InitialCheckout(const char* command) } // Construct the initial checkout command line. - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); std::vector<char const*> vc_co; - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { vc_co.push_back(ai->c_str()); diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 528d0db..5bcfeac 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -182,7 +182,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // ( file , entry ) = "number_executed:timing_info" // ^COVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1 // ( file , entry, line, IGNORE ) =number_executed - std::vector<cmStdString> args; + std::vector<std::string> args; std::string::size_type pos = line.find('(', 0); // if no ( is found, then return line has no coverage if(pos == std::string::npos) diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index 6226feb..6236211 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -122,7 +122,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) glob.RecurseOn(); std::string pat = d; pat += "/*.m"; - glob.FindFiles(pat.c_str()); + glob.FindFiles(pat); std::vector<std::string>& files = glob.GetFiles(); std::vector<std::string>::iterator fileIt; for ( fileIt = files.begin(); fileIt != files.end(); @@ -140,7 +140,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine, std::string& filepath) { - std::map<cmStdString, cmStdString>::iterator i = + std::map<std::string, std::string>::iterator i = this->RoutineToDirectory.find(routine); if(i != this->RoutineToDirectory.end()) { diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h index c1effa7..bc71891 100644 --- a/Source/CTest/cmParseMumpsCoverage.h +++ b/Source/CTest/cmParseMumpsCoverage.h @@ -44,7 +44,7 @@ protected: bool FindMumpsFile(std::string const& routine, std::string& filepath); protected: - std::map<cmStdString, cmStdString> RoutineToDirectory; + std::map<std::string, std::string> RoutineToDirectory; cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; }; diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 1c26c1c..3b7f968 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -34,7 +34,7 @@ bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until) return true; } bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, - cmStdString const& fileName) + std::string const& fileName) { cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector = this->Coverage.TotalCoverage[fileName]; @@ -166,7 +166,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in) // read the string data in.read(s, size-1); s[size-1] = 0; - cmStdString fileName = s; + std::string fileName = s; delete [] s; // read close quote if(in.get(c) && c != '"') diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h index 035a093..92a7634 100644 --- a/Source/CTest/cmParsePHPCoverage.h +++ b/Source/CTest/cmParsePHPCoverage.h @@ -35,7 +35,7 @@ private: bool ReadArraySize(std::istream& in, int& size); bool ReadFileInformation(std::istream& in); bool ReadInt(std::istream& in, int& v); - bool ReadCoverageArray(std::istream& in, cmStdString const&); + bool ReadCoverageArray(std::istream& in, std::string const&); bool ReadUntil(std::istream& in, char until); cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx index 38a770a..2578bb8 100644 --- a/Source/CTest/cmParsePythonCoverage.cxx +++ b/Source/CTest/cmParsePythonCoverage.cxx @@ -20,9 +20,9 @@ public: protected: - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "class") == 0) + if(name == "class") { int tagCount = 0; while(true) @@ -57,7 +57,7 @@ protected: ++tagCount; } } - else if(strcmp(name, "line") == 0) + else if(name == "line") { int tagCount = 0; int curNumber = -1; @@ -85,7 +85,7 @@ protected: } } - virtual void EndElement(const char*) {} + virtual void EndElement(const std::string&) {} private: |