diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-07-27 15:00:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-07-27 14:58:39 (GMT) |
commit | 825b04c67ac7ff3f759fd474e9a16b3b6076d591 (patch) | |
tree | 5b212042a645c3dba30c725b91137ebd870ce59c | |
parent | 7788494257e0a1a22468b5542f9d8c5cb8c3dfed (diff) | |
download | CMake-825b04c67ac7ff3f759fd474e9a16b3b6076d591.zip CMake-825b04c67ac7ff3f759fd474e9a16b3b6076d591.tar.gz CMake-825b04c67ac7ff3f759fd474e9a16b3b6076d591.tar.bz2 |
cmCTest: Members accept std::string parameters
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 10 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildCommand.cxx | 21 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureCommand.cxx | 19 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 21 | ||||
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestHandlerCommand.cxx | 21 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestReadCustomFilesCommand.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestStartCommand.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.cxx | 12 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestCommand.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 12 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 71 | ||||
-rw-r--r-- | Source/cmCTest.h | 26 |
18 files changed, 120 insertions, 131 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index db426b2..a18cbb4 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -182,10 +182,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) std::vector<std::string> extraPaths; std::vector<std::string> failed; fullPath = cmCTestTestHandler::FindExecutable( - this->CTest, this->ConfigSample.c_str(), resultingConfig, extraPaths, - failed); + this->CTest, this->ConfigSample, resultingConfig, extraPaths, failed); if (!fullPath.empty() && !resultingConfig.empty()) { - this->CTest->SetConfigType(resultingConfig.c_str()); + this->CTest->SetConfigType(resultingConfig); } out << "Using config sample with results: " << fullPath << " and " << resultingConfig << std::endl; @@ -296,9 +295,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) extraPaths.push_back(tempPath); } std::vector<std::string> failed; - fullPath = - cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(), - resultingConfig, extraPaths, failed); + fullPath = cmCTestTestHandler::FindExecutable( + this->CTest, this->TestCommand, resultingConfig, extraPaths, failed); if (!cmSystemTools::FileExists(fullPath)) { out << "Could not find path to executable, perhaps it was not built: " diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 44fdc29..f33bdc4 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -12,6 +12,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -38,10 +39,9 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Handler = handler; - const char* ctestBuildCommand = - this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); - if (ctestBuildCommand && *ctestBuildCommand) { - this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand, + cmProp ctestBuildCommand = this->Makefile->GetDef("CTEST_BUILD_COMMAND"); + if (cmNonempty(ctestBuildCommand)) { + this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand, this->Quiet); } else { const char* cmakeGeneratorName = @@ -108,7 +108,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand << "\n", this->Quiet); - this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(), + this->CTest->SetCTestConfiguration("MakeCommand", buildCommand, this->Quiet); } else { std::ostringstream ostr; @@ -123,16 +123,15 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } } - if (const char* useLaunchers = - this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) { - this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers, + if (cmProp useLaunchers = this->Makefile->GetDef("CTEST_USE_LAUNCHERS")) { + this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers, this->Quiet); } - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index f42c3f1..8716b31 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -12,6 +12,7 @@ #include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -38,12 +39,12 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() return nullptr; } - const char* ctestConfigureCommand = - this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); + cmProp ctestConfigureCommand = + this->Makefile->GetDef("CTEST_CONFIGURE_COMMAND"); - if (ctestConfigureCommand && *ctestConfigureCommand) { + if (cmNonempty(ctestConfigureCommand)) { this->CTest->SetCTestConfiguration("ConfigureCommand", - ctestConfigureCommand, this->Quiet); + *ctestConfigureCommand, this->Quiet); } else { const char* cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); @@ -125,8 +126,8 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmakeConfigureCommand += source_dir; cmakeConfigureCommand += "\""; - this->CTest->SetCTestConfiguration( - "ConfigureCommand", cmakeConfigureCommand.c_str(), this->Quiet); + this->CTest->SetCTestConfiguration("ConfigureCommand", + cmakeConfigureCommand, this->Quiet); } else { this->SetError( "Configure command is not specified. If this is a " @@ -136,10 +137,10 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } } - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } cmCTestConfigureHandler* handler = this->CTest->GetConfigureHandler(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index b839c10..093b2d1 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -469,8 +469,8 @@ int cmCTestCoverageHandler::ProcessHandler() } const std::string fileName = cmSystemTools::GetFilenameName(fullFileName); - std::string shortFileName = - this->CTest->GetShortPathToFile(fullFileName.c_str()); + const std::string shortFileName = + this->CTest->GetShortPathToFile(fullFileName); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov = file.second; covLogXML.StartElement("File"); @@ -538,7 +538,7 @@ int cmCTestCoverageHandler::ProcessHandler() covSumXML.StartElement("File"); covSumXML.Attribute("Name", fileName); covSumXML.Attribute("FullPath", - this->CTest->GetShortPathToFile(fullFileName.c_str())); + this->CTest->GetShortPathToFile(fullFileName)); covSumXML.Attribute("Covered", tested + untested > 0 ? "true" : "false"); covSumXML.Element("LOCTested", tested); covSumXML.Element("LOCUnTested", untested); @@ -1887,8 +1887,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( // start the file output covLogXML.StartElement("File"); covLogXML.Attribute("Name", i->first); - covLogXML.Attribute( - "FullPath", this->CTest->GetShortPathToFile(i->second.c_str())); + covLogXML.Attribute("FullPath", + this->CTest->GetShortPathToFile(i->second)); covLogXML.StartElement("Report"); // write the bullseye header line = 0; @@ -2064,8 +2064,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( total_untested += (totalFunctions - functionsCalled); std::string fileName = cmSystemTools::GetFilenameName(file); - std::string shortFileName = - this->CTest->GetShortPathToFile(file.c_str()); + std::string shortFileName = this->CTest->GetShortPathToFile(file); float cper = static_cast<float>(percentBranch + percentFunction); if (totalBranches > 0) { @@ -2266,7 +2265,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) // is the end of the target-wide labels. inTarget = false; - source = this->CTest->GetShortPathToFile(line.c_str()); + source = this->CTest->GetShortPathToFile(line); // Label the source with the target labels. LabelSet& labelSet = this->SourceLabels[source]; @@ -2320,7 +2319,7 @@ bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source) // The source is filtered out if it does not have any labels in // common with the filter set. - std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str()); + std::string shortSrc = this->CTest->GetShortPathToFile(source); auto li = this->SourceLabels.find(shortSrc); if (li != this->SourceLabels.end()) { return !this->IntersectsFilter(li->second); @@ -2342,14 +2341,14 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles( std::vector<std::string> files = gl.GetFiles(); for (std::string const& f : files) { if (this->ShouldIDoCoverage(f, cont->SourceDir, cont->BinaryDir)) { - extraMatches.insert(this->CTest->GetShortPathToFile(f.c_str())); + extraMatches.insert(this->CTest->GetShortPathToFile(f)); } } } if (!extraMatches.empty()) { for (auto const& i : cont->TotalCoverage) { - std::string shortPath = this->CTest->GetShortPathToFile(i.first.c_str()); + std::string shortPath = this->CTest->GetShortPathToFile(i.first); extraMatches.erase(shortPath); } } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index cc0b4ed..a71f550 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -100,7 +100,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, << std::endl); return false; } - this->CTest->AddSubmitFile(part, ostr.str().c_str()); + this->CTest->AddSubmitFile(part, ostr.str()); return true; } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index a755632..03b7173 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -14,6 +14,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" @@ -125,23 +126,21 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, // CTEST_CONFIGURATION_TYPE script variable if it is defined. // The current script value trumps the -C argument on the command // line. - const char* ctestConfigType = - this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE"); + cmProp ctestConfigType = this->Makefile->GetDef("CTEST_CONFIGURATION_TYPE"); if (ctestConfigType) { - this->CTest->SetConfigType(ctestConfigType); + this->CTest->SetConfigType(*ctestConfigType); } if (!this->Build.empty()) { this->CTest->SetCTestConfiguration( - "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build).c_str(), + "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build), this->Quiet); } else { std::string const& bdir = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); if (!bdir.empty()) { this->CTest->SetCTestConfiguration( - "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(), - this->Quiet); + "BuildDirectory", cmSystemTools::CollapseFullPath(bdir), this->Quiet); } else { cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set" << std::endl;); @@ -151,20 +150,18 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, cmCTestLog(this->CTest, DEBUG, "Set source directory to: " << this->Source << std::endl); this->CTest->SetCTestConfiguration( - "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source), this->Quiet); } else { this->CTest->SetCTestConfiguration( "SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")) - .c_str(), + this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")), this->Quiet); } - if (const char* changeId = - this->Makefile->GetDefinition("CTEST_CHANGE_ID")) { - this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet); + if (cmProp changeId = this->Makefile->GetDef("CTEST_CHANGE_ID")) { + this->CTest->SetCTestConfiguration("ChangeId", *changeId, this->Quiet); } cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index d2772a7..822049e 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -354,7 +354,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) cmCTestMemCheckHandler::TestResultsVector::size_type cc; for (cmCTestTestResult const& result : this->TestResults) { std::string testPath = result.Path + "/" + result.Name; - xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); } xml.EndElement(); // TestList cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx index ed14d06..a25cca4 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx +++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx @@ -15,7 +15,7 @@ bool cmCTestReadCustomFilesCommand::InitialPass( } for (std::string const& arg : args) { - this->CTest->ReadCustomConfigurationFileTree(arg.c_str(), this->Makefile); + this->CTest->ReadCustomConfigurationFileTree(arg, this->Makefile); } return true; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 2c8e385..4d65c9b 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -619,11 +619,11 @@ void cmCTestRunTest::ComputeArguments() cmCTestMemCheckHandler* handler = static_cast<cmCTestMemCheckHandler*>(this->TestHandler); this->ActualCommand = handler->MemoryTester; - this->TestProperties->Args[1] = this->TestHandler->FindTheExecutable( - this->TestProperties->Args[1].c_str()); + this->TestProperties->Args[1] = + this->TestHandler->FindTheExecutable(this->TestProperties->Args[1]); } else { - this->ActualCommand = this->TestHandler->FindTheExecutable( - this->TestProperties->Args[1].c_str()); + this->ActualCommand = + this->TestHandler->FindTheExecutable(this->TestProperties->Args[1]); ++j; // skip the executable (it will be actualCommand) } std::string testCommand = diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index fe68406..6398d66 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -94,10 +94,9 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); - this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(), - this->Quiet); - this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(), + this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir, this->Quiet); + this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir, this->Quiet); if (smodel) { cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 279216e..026e98f 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -35,12 +35,12 @@ std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone() cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { - const char* submitURL = !this->SubmitURL.empty() - ? this->SubmitURL.c_str() - : this->Makefile->GetDefinition("CTEST_SUBMIT_URL"); + const std::string* submitURL = !this->SubmitURL.empty() + ? &this->SubmitURL + : this->Makefile->GetDef("CTEST_SUBMIT_URL"); if (submitURL) { - this->CTest->SetCTestConfiguration("SubmitURL", submitURL, this->Quiet); + this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, this->Quiet); } else { this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "DropMethod", "CTEST_DROP_METHOD", this->Quiet); @@ -108,7 +108,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (this->PartsMentioned) { auto parts = cmMakeRange(this->Parts).transform([this](std::string const& arg) { - return this->CTest->GetPartFromName(arg.c_str()); + return this->CTest->GetPartFromName(arg); }); handler->SelectParts(std::set<cmCTest::Part>(parts.begin(), parts.end())); } @@ -177,7 +177,7 @@ void cmCTestSubmitCommand::CheckArguments( !this->Files.empty() || cm::contains(keywords, "FILES"); cm::erase_if(this->Parts, [this](std::string const& arg) -> bool { - cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str()); + cmCTest::Part p = this->CTest->GetPartFromName(arg); if (p == cmCTest::PartCount) { std::ostringstream e; e << "Part name \"" << arg << "\" is invalid."; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index ea36df5..5b54573 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -797,7 +797,7 @@ int cmCTestSubmitHandler::ProcessHandler() gfile = gfile.substr(glen); cmCTestOptionalLog(this->CTest, DEBUG, "Glob file: " << gfile << std::endl, this->Quiet); - this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile.c_str()); + this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile); } } else { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl); diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index c71b409..07ea912 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -13,6 +13,7 @@ #include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" void cmCTestTestCommand::BindArguments() @@ -134,10 +135,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } handler->SetTestLoad(testLoad); - if (const char* labelsForSubprojects = - this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { + if (cmProp labelsForSubprojects = + this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", - labelsForSubprojects, this->Quiet); + *labelsForSubprojects, this->Quiet); } handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d0dbaae..70e84ee 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1374,7 +1374,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("TestList"); for (cmCTestTestResult const& result : this->TestResults) { std::string testPath = result.Path + "/" + result.Name; - xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); } xml.EndElement(); // TestList for (cmCTestTestResult& result : this->TestResults) { @@ -1483,8 +1483,8 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml, } std::string testPath = result.Path + "/" + result.Name; xml.Element("Name", result.Name); - xml.Element("Path", this->CTest->GetShortPathToFile(result.Path.c_str())); - xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str())); + xml.Element("Path", this->CTest->GetShortPathToFile(result.Path)); + xml.Element("FullName", this->CTest->GetShortPathToFile(testPath)); xml.Element("FullCommandLine", result.FullCommandLine); } @@ -1546,12 +1546,12 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) } // Find the appropriate executable to run for a test -std::string cmCTestTestHandler::FindTheExecutable(const char* exe) +std::string cmCTestTestHandler::FindTheExecutable(const std::string& exe) { std::string resConfig; std::vector<std::string> extraPaths; std::vector<std::string> failedPaths; - if (strcmp(exe, "NOT_AVAILABLE") == 0) { + if (exe == "NOT_AVAILABLE") { return exe; } return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig, @@ -1607,7 +1607,7 @@ void cmCTestTestHandler::AddConfigurations( // Find the appropriate executable to run for a test std::string cmCTestTestHandler::FindExecutable( - cmCTest* ctest, const char* testCommand, std::string& resultingConfig, + cmCTest* ctest, const std::string& testCommand, std::string& resultingConfig, std::vector<std::string>& extraPaths, std::vector<std::string>& failed) { // now run the compiled test if we can find it diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 0d88c30..b26f8a6 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -198,7 +198,8 @@ public: std::string filepath, std::string& filename); // full signature static method to find an executable - static std::string FindExecutable(cmCTest* ctest, const char* testCommand, + static std::string FindExecutable(cmCTest* ctest, + const std::string& testCommand, std::string& resultingConfig, std::vector<std::string>& extraPaths, std::vector<std::string>& failed); @@ -309,7 +310,7 @@ private: /** * Find the executable for a test */ - std::string FindTheExecutable(const char* exe); + std::string FindTheExecutable(const std::string& exe); std::string GetTestStatus(cmCTestTestResult const&); void ExpandTestsToRunInformation(size_t numPossibleTests); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 673eb9a..95cae13 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -11,14 +11,13 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() { if (!this->Source.empty()) { this->CTest->SetCTestConfiguration( - "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source), this->Quiet); } else { this->CTest->SetCTestConfiguration( "SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")) - .c_str(), + this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")), this->Quiet); } std::string source_dir = diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4254e2e..a5fde89 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -394,7 +394,7 @@ bool cmCTest::ShouldCompressTestOutput() return this->Impl->CompressTestOutput; } -cmCTest::Part cmCTest::GetPartFromName(const char* name) +cmCTest::Part cmCTest::GetPartFromName(const std::string& name) { // Look up by lower-case to make names case-insensitive. std::string lower_name = cmSystemTools::LowerCase(name); @@ -458,8 +458,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); cmMakefile mf(&gg, cm.GetCurrentSnapshot()); - if (!this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir.c_str(), - &mf)) { + if (!this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, &mf)) { cmCTestOptionalLog( this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); @@ -523,7 +522,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) std::string model; if (cmSystemTools::GetLineFromStream(tfin, model) && !this->Impl->Parts[PartStart] && !command) { - this->Impl->TestModel = GetTestModelFromString(model.c_str()); + this->Impl->TestModel = GetTestModelFromString(model); } tfin.close(); } @@ -579,7 +578,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cmSystemTools::GetLineFromStream(tfin, tag); cmSystemTools::GetLineFromStream(tfin, group); if (cmSystemTools::GetLineFromStream(tfin, modelStr)) { - model = GetTestModelFromString(modelStr.c_str()); + model = GetTestModelFromString(modelStr); } tfin.close(); } @@ -793,7 +792,7 @@ int cmCTest::GetTestModel() const return this->Impl->TestModel; } -bool cmCTest::SetTest(const char* ttype, bool report) +bool cmCTest::SetTest(const std::string& ttype, bool report) { if (cmSystemTools::LowerCase(ttype) == "all") { for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { @@ -856,7 +855,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name, return true; } -bool cmCTest::AddIfExists(Part part, const char* file) +bool cmCTest::AddIfExists(Part part, const std::string& file) { if (this->CTestFileExists(file)) { this->AddSubmitFile(part, file); @@ -1008,7 +1007,7 @@ int cmCTest::ProcessSteps() if (this->Impl->Parts[PartNotes]) { this->UpdateCTestConfiguration(); if (!this->Impl->NotesFiles.empty()) { - this->GenerateNotesFile(this->Impl->NotesFiles.c_str()); + this->GenerateNotesFile(this->Impl->NotesFiles); } } if (this->Impl->Parts[PartSubmit]) { @@ -1037,9 +1036,9 @@ std::string cmCTest::GetTestModelString() return "Experimental"; } -int cmCTest::GetTestModelFromString(const char* str) +int cmCTest::GetTestModelFromString(const std::string& str) { - if (!str) { + if (str.empty()) { return cmCTest::EXPERIMENTAL; } std::string rstr = cmSystemTools::LowerCase(str); @@ -1565,9 +1564,9 @@ int cmCTest::GenerateNotesFile(std::vector<std::string> const& files) return 0; } -int cmCTest::GenerateNotesFile(const char* cfiles) +int cmCTest::GenerateNotesFile(const std::string& cfiles) { - if (!cfiles) { + if (cfiles.empty()) { return 1; } @@ -1650,14 +1649,14 @@ bool cmCTest::SubmitExtraFiles(std::vector<std::string> const& files) << std::endl;); return false; } - this->AddSubmitFile(PartExtraFiles, file.c_str()); + this->AddSubmitFile(PartExtraFiles, file); } return true; } -bool cmCTest::SubmitExtraFiles(const char* cfiles) +bool cmCTest::SubmitExtraFiles(const std::string& cfiles) { - if (!cfiles) { + if (cfiles.empty()) { return true; } @@ -1941,7 +1940,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, else if (this->CheckArgument(arg, "-C"_s, "--build-config") && i < args.size() - 1) { i++; - this->SetConfigType(args[i].c_str()); + this->SetConfigType(args[i]); } else if (this->CheckArgument(arg, "--debug"_s)) { @@ -2016,7 +2015,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, else if (this->CheckArgument(arg, "-O"_s, "--output-log") && i < args.size() - 1) { i++; - this->SetOutputLogFileName(args[i].c_str()); + this->SetOutputLogFileName(args[i]); } else if (this->CheckArgument(arg, "--tomorrow-tag"_s)) { @@ -2048,7 +2047,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, this->Impl->ProduceXML = true; this->SetTest("Notes"); i++; - this->SetNotesFiles(args[i].c_str()); + this->SetNotesFiles(args[i]); return true; } @@ -2305,7 +2304,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) this->Impl->ProduceXML = true; this->SetTest("Submit"); i++; - if (!this->SubmitExtraFiles(args[i].c_str())) { + if (!this->SubmitExtraFiles(args[i])) { return 0; } } @@ -2376,7 +2375,7 @@ bool cmCTest::HandleTestActionArgument(const char* ctestExec, size_t& i, (i < args.size() - 1)) { this->Impl->ProduceXML = true; i++; - if (!this->SetTest(args[i].c_str(), false)) { + if (!this->SetTest(args[i], false)) { success = false; cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " << args[i] @@ -2491,11 +2490,8 @@ int cmCTest::RunCMakeAndTest(std::string* output) return retv; } -void cmCTest::SetNotesFiles(const char* notes) +void cmCTest::SetNotesFiles(const std::string& notes) { - if (!notes) { - return; - } this->Impl->NotesFiles = notes; } @@ -2561,7 +2557,8 @@ void cmCTest::SetScheduleType(std::string const& type) this->Impl->ScheduleType = type; } -int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) +int cmCTest::ReadCustomConfigurationFileTree(const std::string& dir, + cmMakefile* mf) { bool found = false; cmCTestLog(this, DEBUG, @@ -2648,7 +2645,7 @@ void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def, val = atoi(dval); } -std::string cmCTest::GetShortPathToFile(const char* cfname) +std::string cmCTest::GetShortPathToFile(const std::string& cfname) { const std::string& sourceDir = cmSystemTools::CollapseFullPath( this->GetCTestConfiguration("SourceDirectory")); @@ -2712,18 +2709,17 @@ void cmCTest::EmptyCTestConfiguration() this->Impl->CTestConfiguration.clear(); } -void cmCTest::SetCTestConfiguration(const char* name, const char* value, +void cmCTest::SetCTestConfiguration(const char* name, const std::string& value, bool suppress) { cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, - "SetCTestConfiguration:" - << name << ":" << (value ? value : "(null)") << "\n", + "SetCTestConfiguration:" << name << ":" << value << "\n", suppress); if (!name) { return; } - if (!value) { + if (value.empty()) { this->Impl->CTestConfiguration.erase(name); return; } @@ -2928,7 +2924,7 @@ std::string cmCTest::GetBuildID() const return this->Impl->BuildID; } -void cmCTest::AddSubmitFile(Part part, const char* name) +void cmCTest::AddSubmitFile(Part part, const std::string& name) { this->Impl->Parts[part].SubmitFiles.emplace_back(name); } @@ -2964,9 +2960,9 @@ void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) this->Impl->CTestConfigurationOverwrites[key] = value; } -void cmCTest::SetConfigType(const char* ct) +void cmCTest::SetConfigType(const std::string& ct) { - this->Impl->ConfigType = ct ? ct : ""; + this->Impl->ConfigType = ct; cmSystemTools::ReplaceString(this->Impl->ConfigType, ".\\", ""); std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->Impl->ConfigType; cmSystemTools::PutEnv(confTypeEnv); @@ -2976,8 +2972,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( cmMakefile* mf, const char* dconfig, const std::string& cmake_var, bool suppress) { - const char* ctvar; - ctvar = mf->GetDefinition(cmake_var); + cmProp ctvar = mf->GetDef(cmake_var); if (!ctvar) { return false; } @@ -2985,7 +2980,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( "SetCTestConfigurationFromCMakeVariable:" << dconfig << ":" << cmake_var << std::endl, suppress); - this->SetCTestConfiguration(dconfig, ctvar, suppress); + this->SetCTestConfiguration(dconfig, *ctvar, suppress); return true; } @@ -3086,9 +3081,9 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args, return result; } -void cmCTest::SetOutputLogFileName(const char* name) +void cmCTest::SetOutputLogFileName(const std::string& name) { - if (name) { + if (!name.empty()) { this->Impl->OutputLogFile = cm::make_unique<cmGeneratedFileStream>(name); } else { this->Impl->OutputLogFile.reset(); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index a39b8fe..1e0fb8c 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -64,7 +64,7 @@ public: /** Get a testing part id from its string name. Returns PartCount if the string does not name a valid part. */ - Part GetPartFromName(const char* name); + Part GetPartFromName(const std::string& name); /** Process Command line arguments */ int Run(std::vector<std::string>&, std::string* output = nullptr); @@ -127,12 +127,12 @@ public: * Check if CTest file exists */ bool CTestFileExists(const std::string& filename); - bool AddIfExists(Part part, const char* file); + bool AddIfExists(Part part, const std::string& file); /** * Set the cmake test */ - bool SetTest(const char*, bool report = true); + bool SetTest(const std::string&, bool report = true); /** * Set the cmake test mode (experimental, nightly, continuous). @@ -141,11 +141,11 @@ public: int GetTestModel() const; std::string GetTestModelString(); - static int GetTestModelFromString(const char* str); + static int GetTestModelFromString(const std::string& str); static std::string CleanString(const std::string& str, std::string::size_type spos = 0); std::string GetCTestConfiguration(const std::string& name); - void SetCTestConfiguration(const char* name, const char* value, + void SetCTestConfiguration(const char* name, const std::string& value, bool suppress = false); void EmptyCTestConfiguration(); @@ -161,7 +161,7 @@ public: cmCTest& operator=(const cmCTest&) = delete; /** Set the notes files to be created. */ - void SetNotesFiles(const char* notes); + void SetNotesFiles(const std::string& notes); void PopulateCustomVector(cmMakefile* mf, const std::string& definition, std::vector<std::string>& vec); @@ -272,7 +272,7 @@ public: * This means if the file is in binary or * source directory, it will become /.../relative/path/to/file */ - std::string GetShortPathToFile(const char* fname); + std::string GetShortPathToFile(const std::string& fname); enum { @@ -354,14 +354,14 @@ public: int GenerateDoneFile(); /** Submit extra files to the server */ - bool SubmitExtraFiles(const char* files); + bool SubmitExtraFiles(const std::string& files); bool SubmitExtraFiles(std::vector<std::string> const& files); /** Set the output log file name */ - void SetOutputLogFileName(const char* name); + void SetOutputLogFileName(const std::string& name); /** Set the visual studio or Xcode config type */ - void SetConfigType(const char* ct); + void SetConfigType(const std::string& ct); /** Various log types */ enum @@ -399,14 +399,14 @@ public: std::string GetBuildID() const; /** Add file to be submitted */ - void AddSubmitFile(Part part, const char* name); + void AddSubmitFile(Part part, const std::string& name); std::vector<std::string> const& GetSubmitFiles(Part part) const; void ClearSubmitFiles(Part part); /** * Read the custom configuration files and apply them to the current ctest */ - int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); + int ReadCustomConfigurationFileTree(const std::string& dir, cmMakefile* mf); std::vector<std::string>& GetInitialCommandLineArguments(); @@ -462,7 +462,7 @@ public: void SetRunCurrentScript(bool value); private: - int GenerateNotesFile(const char* files); + int GenerateNotesFile(const std::string& files); void BlockTestErrorDiagnostics(); |