diff options
Diffstat (limited to 'Source/CTest')
37 files changed, 238 insertions, 307 deletions
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index b154caf..83aeb64 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -365,7 +365,7 @@ bool cmCTestBZR::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 2fd4c7a..a7d4455 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -118,7 +118,7 @@ public: : CM(cm) { cmSystemTools::SetMessageCallback( - [&s](const char* msg, const char* /*unused*/) { + [&s](const std::string& msg, const char* /*unused*/) { s += msg; s += "\n"; }); @@ -126,10 +126,11 @@ public: cmSystemTools::SetStdoutCallback([&s](std::string const& m) { s += m; }); cmSystemTools::SetStderrCallback([&s](std::string const& m) { s += m; }); - this->CM.SetProgressCallback([&s](const char* msg, float /*unused*/) { - s += msg; - s += "\n"; - }); + this->CM.SetProgressCallback( + [&s](const std::string& msg, float /*unused*/) { + s += msg; + s += "\n"; + }); } ~cmCTestBuildAndTestCaptureRAII() @@ -139,6 +140,11 @@ public: cmSystemTools::SetStdoutCallback(nullptr); cmSystemTools::SetMessageCallback(nullptr); } + + cmCTestBuildAndTestCaptureRAII(const cmCTestBuildAndTestCaptureRAII&) = + delete; + cmCTestBuildAndTestCaptureRAII& operator=( + const cmCTestBuildAndTestCaptureRAII&) = delete; }; int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) @@ -250,7 +256,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } int retVal = cm.GetGlobalGenerator()->Build( cmake::NO_BUILD_PARALLEL_LEVEL, this->SourceDir, this->BinaryDir, - this->BuildProject, tar, output, this->BuildMakeProgram, config, + this->BuildProject, { tar }, output, this->BuildMakeProgram, config, !this->BuildNoClean, false, false, remainingTime); out << output; // if the build failed then return diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 32f7496..2eacaf1 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -4,7 +4,6 @@ #include "cmCTest.h" #include "cmCTestBuildHandler.h" -#include "cmCTestGenericHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -39,12 +38,10 @@ cmCTestBuildCommand::~cmCTestBuildCommand() cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() { - cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build"); - if (!handler) { - this->SetError("internal CTest error. Cannot instantiate build handler"); - return nullptr; - } - this->Handler = static_cast<cmCTestBuildHandler*>(handler); + cmCTestBuildHandler* handler = this->CTest->GetBuildHandler(); + handler->Initialize(); + + this->Handler = handler; const char* ctestBuildCommand = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index d934c00..8ea9a83 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -5,7 +5,7 @@ #include "cmAlgorithms.h" #include "cmCTest.h" #include "cmDuration.h" -#include "cmFileTimeComparison.h" +#include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmProcessOutput.h" @@ -418,8 +418,8 @@ int cmCTestBuildHandler::ProcessHandler() int retVal = 0; int res = cmsysProcess_State_Exited; if (!this->CTest->GetShowOnly()) { - res = this->RunMakeCommand(makeCommand.c_str(), &retVal, - buildDirectory.c_str(), 0, ofs); + res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0, + ofs); } else { cmCTestOptionalLog(this->CTest, DEBUG, "Build with command: " << makeCommand << std::endl, @@ -503,7 +503,7 @@ void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml) class cmCTestBuildHandler::FragmentCompare { public: - FragmentCompare(cmFileTimeComparison* ftc) + FragmentCompare(cmFileTimeCache* ftc) : FTC(ftc) { } @@ -513,14 +513,14 @@ public: // Order files by modification time. Use lexicographic order // among files with the same time. int result; - if (this->FTC->FileTimeCompare(l, r, &result) && result != 0) { + if (this->FTC->Compare(l, r, &result) && result != 0) { return result < 0; } return l < r; } private: - cmFileTimeComparison* FTC = nullptr; + cmFileTimeCache* FTC = nullptr; }; void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml) @@ -530,7 +530,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml) } // Sort XML fragments in chronological order. - cmFileTimeComparison ftc; + cmFileTimeCache ftc; FragmentCompare fragmentCompare(&ftc); typedef std::set<std::string, FragmentCompare> Fragments; Fragments fragments(fragmentCompare); @@ -680,6 +680,8 @@ class cmCTestBuildHandler::LaunchHelper public: LaunchHelper(cmCTestBuildHandler* handler); ~LaunchHelper(); + LaunchHelper(const LaunchHelper&) = delete; + LaunchHelper& operator=(const LaunchHelper&) = delete; private: cmCTestBuildHandler* Handler; @@ -764,9 +766,10 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers( } } -int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, - const char* dir, int timeout, - std::ostream& ofs, Encoding encoding) +int cmCTestBuildHandler::RunMakeCommand(const std::string& command, + int* retVal, const char* dir, + int timeout, std::ostream& ofs, + Encoding encoding) { // First generate the command and arguments std::vector<std::string> args = cmSystemTools::ParseArguments(command); @@ -800,7 +803,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, // Now create process object cmsysProcess* cp = cmsysProcess_New(); - cmsysProcess_SetCommand(cp, &*argv.begin()); + cmsysProcess_SetCommand(cp, argv.data()); cmsysProcess_SetWorkingDirectory(cp, dir); cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); cmsysProcess_SetTimeout(cp, timeout); @@ -978,7 +981,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(), queue->begin(), it); this->CurrentProcessingLine.push_back(0); - const char* line = &*this->CurrentProcessingLine.begin(); + const char* line = this->CurrentProcessingLine.data(); // Process the line int lineType = this->ProcessSingleLine(line); diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index a9b121b..722c590 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -52,7 +52,7 @@ private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. - int RunMakeCommand(const char* command, int* retVal, const char* dir, + int RunMakeCommand(const std::string& command, int* retVal, const char* dir, int timeout, std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 6e8f73f..9c03839 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -78,7 +78,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 7b5c3bc..74a932a 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -3,7 +3,7 @@ #include "cmCTestConfigureCommand.h" #include "cmCTest.h" -#include "cmCTestGenericHandler.h" +#include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -142,13 +142,8 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() labelsForSubprojects, this->Quiet); } - cmCTestGenericHandler* handler = - this->CTest->GetInitializedHandler("configure"); - if (!handler) { - this->SetError( - "internal CTest error. Cannot instantiate configure handler"); - return nullptr; - } + cmCTestConfigureHandler* handler = this->CTest->GetConfigureHandler(); + handler->Initialize(); handler->SetQuiet(this->Quiet); return handler; } diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 6b7601b..7e93189 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -61,7 +61,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand << std::endl, this->Quiet); - res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal, + res = this->CTest->RunMakeCommand(cCommand, output, &retVal, buildDirectory.c_str(), cmDuration::zero(), ofs); diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index d2003ba..07aae76 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -19,12 +19,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Quiet); - cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>( - this->CTest->GetInitializedHandler("coverage")); - if (!handler) { - this->SetError("internal CTest error. Cannot instantiate test handler"); - return nullptr; - } + cmCTestCoverageHandler* handler = this->CTest->GetCoverageHandler(); + handler->Initialize(); // If a LABELS option was given, select only files with the labels. if (this->LabelsMentioned) { diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 225383c..d76bd2a 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -52,6 +52,8 @@ public: } cmsysProcess_Delete(this->Process); } + cmCTestRunProcess(const cmCTestRunProcess&) = delete; + cmCTestRunProcess& operator=(const cmCTestRunProcess&) = delete; void SetCommand(const char* command) { this->CommandLineStrings.clear(); @@ -72,7 +74,7 @@ public: args.push_back(cl.c_str()); } args.push_back(nullptr); // null terminate - cmsysProcess_SetCommand(this->Process, &*args.begin()); + cmsysProcess_SetCommand(this->Process, args.data()); if (!this->WorkingDirectory.empty()) { cmsysProcess_SetWorkingDirectory(this->Process, this->WorkingDirectory.c_str()); @@ -223,7 +225,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, checkDir = fBinDir; } std::string ndc = cmSystemTools::FileExistsInParentDirectories( - ".NoDartCoverage", fFile.c_str(), checkDir.c_str()); + ".NoDartCoverage", fFile, checkDir); if (!ndc.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of " << file @@ -254,8 +256,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, return true; } - ndc = cmSystemTools::FileExistsInParentDirectories( - ".NoDartCoverage", fFile.c_str(), checkDir.c_str()); + ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage", fFile, + checkDir); if (!ndc.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of: " << file @@ -786,6 +788,9 @@ struct cmCTestCoverageHandlerLocale cmSystemTools::UnsetEnv("LC_ALL"); } } + cmCTestCoverageHandlerLocale(const cmCTestCoverageHandlerLocale&) = delete; + cmCTestCoverageHandlerLocale& operator=( + const cmCTestCoverageHandlerLocale&) = delete; std::string lc_all; }; @@ -999,7 +1004,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( static_cast<void>(locale_C); std::vector<std::string> basecovargs = - cmSystemTools::ParseArguments(gcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(gcovExtraFlags); basecovargs.insert(basecovargs.begin(), gcovCommand); basecovargs.emplace_back("-o"); @@ -1058,8 +1063,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( this->Quiet); std::vector<std::string> lines; - - cmSystemTools::Split(output.c_str(), lines); + cmsys::SystemTools::Split(output, lines); for (std::string const& line : lines) { std::string sourceFile; @@ -1373,7 +1377,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( static_cast<void>(locale_C); std::vector<std::string> covargs = - cmSystemTools::ParseArguments(lcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(lcovExtraFlags); covargs.insert(covargs.begin(), lcovCommand); const std::string command = joinCommandLine(covargs); @@ -1435,8 +1439,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( this->Quiet); std::vector<std::string> lines; - - cmSystemTools::Split(output.c_str(), lines); + cmsys::SystemTools::Split(output, lines); for (std::string const& line : lines) { std::string sourceFile; diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h index 86d9489..6186af8 100644 --- a/Source/CTest/cmCTestCurl.h +++ b/Source/CTest/cmCTestCurl.h @@ -16,6 +16,8 @@ class cmCTestCurl public: cmCTestCurl(cmCTest*); ~cmCTestCurl(); + cmCTestCurl(const cmCTestCurl&) = delete; + cmCTestCurl& operator=(const cmCTestCurl&) = delete; bool UploadFile(std::string const& local_file, std::string const& url, std::string const& fields, std::string& response); bool HttpRequest(std::string const& url, std::string const& fields, diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 210abe5..11cd005 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -162,7 +162,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { git_fetch.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 6fb99d8..727c59c 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -144,7 +144,7 @@ bool cmCTestHG::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { hg_update.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 57a14ef..adf9553 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -76,6 +76,8 @@ public: } } } + SaveRestoreErrorState(const SaveRestoreErrorState&) = delete; + SaveRestoreErrorState& operator=(const SaveRestoreErrorState&) = delete; private: bool InitialErrorState; diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index debbe59..107fd61 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -28,6 +28,9 @@ private: cmCTestLaunch(int argc, const char* const* argv); ~cmCTestLaunch(); + cmCTestLaunch(const cmCTestLaunch&) = delete; + cmCTestLaunch& operator=(const cmCTestLaunch&) = delete; + // Run the real command. int Run(); void RunChild(); diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index a5d5995..7dad1ce 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -7,7 +7,6 @@ #include <vector> #include "cmCTest.h" -#include "cmCTestGenericHandler.h" #include "cmCTestMemCheckHandler.h" #include "cmMakefile.h" @@ -20,8 +19,8 @@ cmCTestMemCheckCommand::cmCTestMemCheckCommand() cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() { - cmCTestGenericHandler* handler = - this->CTest->GetInitializedHandler("memcheck"); + cmCTestMemCheckHandler* handler = this->CTest->GetMemCheckHandler(); + handler->Initialize(); this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8ba59d3..22c8469 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -520,7 +520,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->CTest->GetCTestConfiguration("ValgrindCommandOptions"); } this->MemoryTesterOptions = - cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); + cmSystemTools::ParseArguments(memoryTesterOptions); this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log"; @@ -725,7 +725,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*"); int defects = 0; std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); std::ostringstream ostr; log.clear(); for (std::string const& l : lines) { @@ -755,7 +755,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( const std::string& str, std::string& log, std::vector<int>& results) { std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); std::ostringstream ostr; log.clear(); @@ -798,7 +798,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( const std::string& str, std::string& log, std::vector<int>& results) { std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); bool unlimitedOutput = false; if (str.find("CTEST_FULL_OUTPUT") != std::string::npos || this->CustomMaximumFailedTestOutputSize == 0) { @@ -937,7 +937,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( log.clear(); auto sttime = std::chrono::steady_clock::now(); std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); cmCTestOptionalLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl, this->Quiet); std::vector<std::string>::size_type cc; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 756ac6c..477161a 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -8,6 +8,7 @@ #include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmListFileCache.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" @@ -108,8 +109,8 @@ void cmCTestMultiProcessHandler::SetTestLoad(unsigned long load) fake_load_value)) { if (!cmSystemTools::StringToULong(fake_load_value.c_str(), &this->FakeLoadForTesting)) { - cmSystemTools::Error("Failed to parse fake load value: ", - fake_load_value.c_str()); + cmSystemTools::Error("Failed to parse fake load value: " + + fake_load_value); } } } @@ -651,9 +652,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() // Reverse iterate over the different dependency levels (deepest first). // Sort tests within each level by COST and append them to the cost list. - for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin(); - i != priorityStack.rend(); ++i) { - TestSet const& currentSet = *i; + for (TestSet const& currentSet : cmReverseRange(priorityStack)) { TestComparator comp(this); TestList sortedCopy; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 435be97..7adf640 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -5,6 +5,7 @@ #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" +#include "cmRange.h" #include "cmSystemTools.h" #include "cmsys/RegularExpression.hxx" @@ -323,8 +324,7 @@ 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<std::string> args = - cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); P4Options.insert(P4Options.end(), args.begin(), args.end()); } @@ -425,12 +425,11 @@ bool cmCTestP4::LoadRevisions() // p4 describe -s ...@1111111,2222222 std::vector<char const*> p4_describe; - for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin(); - i != ChangeLists.rend(); ++i) { + for (std::string const& i : cmReverseRange(ChangeLists)) { SetP4Options(p4_describe); p4_describe.push_back("describe"); p4_describe.push_back("-s"); - p4_describe.push_back(i->c_str()); + p4_describe.push_back(i.c_str()); p4_describe.push_back(nullptr); DescribeParser outDescribe(this, "p4_describe-out> "); @@ -501,7 +500,7 @@ bool cmCTestP4::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { p4_sync.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 7f081ef..31976b9 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -9,11 +9,10 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" -#include "cm_zlib.h" -#include "cmsys/Base64.h" #include "cmsys/RegularExpression.hxx" #include <chrono> #include <cmAlgorithms.h> +#include <cstdint> #include <cstring> #include <iomanip> #include <ratio> @@ -31,9 +30,6 @@ cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler) this->TestResult.Status = cmCTestTestHandler::NOT_RUN; this->TestResult.TestCount = 0; this->TestResult.Properties = nullptr; - this->ProcessOutput.clear(); - this->CompressedOutput.clear(); - this->CompressionRatio = 2; this->NumberOfRunsLeft = 1; // default to 1 run of the test this->RunUntilFail = false; // default to run the test once this->RunAgain = false; // default to not having to run again @@ -68,73 +64,8 @@ void cmCTestRunTest::CheckOutput(std::string const& line) } } -// Streamed compression of test output. The compressed data -// is appended to this->CompressedOutput -void cmCTestRunTest::CompressOutput() -{ - int ret; - z_stream strm; - - unsigned char* in = reinterpret_cast<unsigned char*>( - const_cast<char*>(this->ProcessOutput.c_str())); - // zlib makes the guarantee that this is the maximum output size - int outSize = static_cast<int>( - static_cast<double>(this->ProcessOutput.size()) * 1.001 + 13.0); - unsigned char* out = new unsigned char[outSize]; - - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - ret = deflateInit(&strm, -1); // default compression level - if (ret != Z_OK) { - delete[] out; - return; - } - - strm.avail_in = static_cast<uInt>(this->ProcessOutput.size()); - strm.next_in = in; - strm.avail_out = outSize; - strm.next_out = out; - ret = deflate(&strm, Z_FINISH); - - if (ret != Z_STREAM_END) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Error during output compression. Sending uncompressed output." - << std::endl); - delete[] out; - return; - } - - (void)deflateEnd(&strm); - - unsigned char* encoded_buffer = - new unsigned char[static_cast<int>(outSize * 1.5)]; - - size_t rlen = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1); - - this->CompressedOutput.clear(); - for (size_t i = 0; i < rlen; i++) { - this->CompressedOutput += encoded_buffer[i]; - } - - if (strm.total_in) { - this->CompressionRatio = - static_cast<double>(strm.total_out) / static_cast<double>(strm.total_in); - } - - delete[] encoded_buffer; - delete[] out; -} - bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { - if ((!this->TestHandler->MemCheck && - this->CTest->ShouldCompressTestOutput()) || - (this->TestHandler->MemCheck && - this->CTest->ShouldCompressTestOutput())) { - this->CompressOutput(); - } - this->WriteLogOutputTop(completed, total); std::string reason; bool passed = true; @@ -143,7 +74,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) if (res != cmProcess::State::Expired) { this->TimeoutIsForStopTime = false; } - int retVal = this->TestProcess->GetExitValue(); + std::int64_t retVal = this->TestProcess->GetExitValue(); bool forceFail = false; bool skipped = false; bool outputTestErrorsToConsole = false; @@ -201,14 +132,17 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) } else { this->TestResult.Status = cmCTestTestHandler::FAILED; outputStream << "***Failed " << reason; - outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; + outputTestErrorsToConsole = + this->CTest->GetOutputTestOutputOnTestFailure(); } } else if (res == cmProcess::State::Expired) { outputStream << "***Timeout "; this->TestResult.Status = cmCTestTestHandler::TIMEOUT; - outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; + outputTestErrorsToConsole = + this->CTest->GetOutputTestOutputOnTestFailure(); } else if (res == cmProcess::State::Exception) { - outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure; + outputTestErrorsToConsole = + this->CTest->GetOutputTestOutputOnTestFailure(); outputStream << "***Exception: "; this->TestResult.ExceptionStatus = this->TestProcess->GetExitExceptionString(); @@ -335,10 +269,18 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // if the test actually started and ran // record the results in TestResult if (started) { - bool compress = !this->TestHandler->MemCheck && - this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput(); + std::string compressedOutput; + if (!this->TestHandler->MemCheck && + this->CTest->ShouldCompressTestOutput()) { + std::string str = this->ProcessOutput; + if (this->CTest->CompressString(str)) { + compressedOutput = std::move(str); + } + } + bool compress = !compressedOutput.empty() && + compressedOutput.length() < this->ProcessOutput.length(); this->TestResult.Output = - compress ? this->CompressedOutput : this->ProcessOutput; + compress ? compressedOutput : this->ProcessOutput; this->TestResult.CompressOutput = compress; this->TestResult.ReturnValue = this->TestProcess->GetExitValue(); if (!skipped) { @@ -493,32 +435,26 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total) this->ProcessOutput.clear(); + this->TestResult.Properties = this->TestProperties; + this->TestResult.ExecutionTime = cmDuration::zero(); + this->TestResult.CompressOutput = false; + this->TestResult.ReturnValue = -1; + this->TestResult.TestCount = this->TestProperties->Index; + this->TestResult.Name = this->TestProperties->Name; + this->TestResult.Path = this->TestProperties->Directory; + // Return immediately if test is disabled if (this->TestProperties->Disabled) { - this->TestResult.Properties = this->TestProperties; - this->TestResult.ExecutionTime = cmDuration::zero(); - this->TestResult.CompressOutput = false; - this->TestResult.ReturnValue = -1; this->TestResult.CompletionStatus = "Disabled"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; - this->TestResult.TestCount = this->TestProperties->Index; - this->TestResult.Name = this->TestProperties->Name; - this->TestResult.Path = this->TestProperties->Directory; this->TestProcess = cm::make_unique<cmProcess>(*this); this->TestResult.Output = "Disabled"; this->TestResult.FullCommandLine.clear(); return false; } - this->TestResult.Properties = this->TestProperties; - this->TestResult.ExecutionTime = cmDuration::zero(); - this->TestResult.CompressOutput = false; - this->TestResult.ReturnValue = -1; this->TestResult.CompletionStatus = "Failed to start"; this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND; - this->TestResult.TestCount = this->TestProperties->Index; - this->TestResult.Name = this->TestProperties->Name; - this->TestResult.Path = this->TestProperties->Directory; // Check for failed fixture dependencies before we even look at the command // arguments because if we are not going to run the test, the command and @@ -696,9 +632,8 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout, { this->TestProcess = cm::make_unique<cmProcess>(*this); this->TestProcess->SetId(this->Index); - this->TestProcess->SetWorkingDirectory( - this->TestProperties->Directory.c_str()); - this->TestProcess->SetCommand(this->ActualCommand.c_str()); + this->TestProcess->SetWorkingDirectory(this->TestProperties->Directory); + this->TestProcess->SetCommand(this->ActualCommand); this->TestProcess->SetCommandArguments(this->Arguments); // determine how much time we have diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 918d5fa..38cc417 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -58,9 +58,6 @@ public: // Read and store output. Returns true if it must be called again. void CheckOutput(std::string const& line); - // Compresses the output, writing to CompressedOutput - void CompressOutput(); - // launch the test process, return whether it started correctly bool StartTest(size_t completed, size_t total); // capture and report the test results @@ -105,8 +102,6 @@ private: cmCTest* CTest; std::unique_ptr<cmProcess> TestProcess; std::string ProcessOutput; - std::string CompressedOutput; - double CompressionRatio; // The test results cmCTestTestHandler::cmCTestTestResult TestResult; cmCTestMultiProcessHandler& MultiTestHandler; diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 3bf66ca..b7a4e4c 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -242,7 +242,7 @@ bool cmCTestSVN::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { @@ -277,7 +277,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); std::vector<std::string> parsedUserOptions = - cmSystemTools::ParseArguments(userOptions.c_str()); + cmSystemTools::ParseArguments(userOptions); for (std::string const& opt : parsedUserOptions) { args.push_back(opt.c_str()); } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 33b8b4a..43cfe16 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -199,7 +199,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) // Now create process object cmsysProcess* cp = cmsysProcess_New(); - cmsysProcess_SetCommand(cp, &*argv.begin()); + cmsysProcess_SetCommand(cp, argv.data()); // cmsysProcess_SetWorkingDirectory(cp, dir); cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); // cmsysProcess_SetTimeout(cp, timeout); @@ -288,11 +288,12 @@ void cmCTestScriptHandler::CreateCMake() this->ParentMakefile->GetRecursionDepth()); } - this->CMake->SetProgressCallback([this](const char* m, float /*unused*/) { - if (m && *m) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl); - } - }); + this->CMake->SetProgressCallback( + [this](const std::string& m, float /*unused*/) { + if (!m.empty()) { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl); + } + }); this->AddCTestCommand("ctest_build", new cmCTestBuildCommand); this->AddCTestCommand("ctest_configure", new cmCTestConfigureCommand); @@ -330,7 +331,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) } // make sure the file exists if (!cmSystemTools::FileExists(script)) { - cmSystemTools::Error("Cannot find file: ", script.c_str()); + cmSystemTools::Error("Cannot find file: " + script); return 1; } @@ -470,8 +471,8 @@ int cmCTestScriptHandler::ExtractVariables() msg += "\nCTEST_COMMAND = "; msg += (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)"; cmSystemTools::Error( - "Some required settings in the configuration file were missing:\n", - msg.c_str()); + "Some required settings in the configuration file were missing:\n" + + msg); return 4; } @@ -607,12 +608,10 @@ int cmCTestScriptHandler::CheckOutSourceDir() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << this->CVSCheckOut << std::endl); res = cmSystemTools::RunSingleCommand( - this->CVSCheckOut.c_str(), &output, &output, &retVal, - this->CTestRoot.c_str(), this->HandlerVerbose, - cmDuration::zero() /*this->TimeOut*/); + this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(), + this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform cvs checkout:\n", - output.c_str()); + cmSystemTools::Error("Unable to perform cvs checkout:\n" + output); return 6; } } @@ -675,11 +674,11 @@ int cmCTestScriptHandler::PerformExtraUpdates() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " << fullCommand << std::endl); res = cmSystemTools::RunSingleCommand( - fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(), + fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform extra updates:\n", eu.c_str(), - "\nWith output:\n", output.c_str()); + cmSystemTools::Error("Unable to perform extra updates:\n" + eu + + "\nWith output:\n" + output); return 0; } } @@ -721,8 +720,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() if (!cmSystemTools::FileExists(this->BinaryDir) && this->SourceDir != this->BinaryDir) { if (!cmSystemTools::MakeDirectory(this->BinaryDir)) { - cmSystemTools::Error("Unable to create the binary directory:\n", - this->BinaryDir.c_str()); + cmSystemTools::Error("Unable to create the binary directory:\n" + + this->BinaryDir); this->RestoreBackupDirectories(); return 7; } @@ -779,7 +778,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command << std::endl); res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), + command, &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!this->CMOutFile.empty()) { @@ -818,7 +817,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command << std::endl); res = cmSystemTools::RunSingleCommand( - command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), + command, &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); // did something critical fail in ctest diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 00c0610..afc3e67 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -3,7 +3,6 @@ #include "cmCTestSubmitCommand.h" #include "cmCTest.h" -#include "cmCTestGenericHandler.h" #include "cmCTestSubmitHandler.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -13,6 +12,29 @@ class cmExecutionStatus; +cmCTestSubmitCommand::cmCTestSubmitCommand() +{ + this->PartsMentioned = false; + this->FilesMentioned = false; + this->InternalTest = false; + this->RetryCount = ""; + this->RetryDelay = ""; + this->CDashUpload = false; + this->Arguments[cts_BUILD_ID] = "BUILD_ID"; + this->Last = cts_LAST; +} + +/** + * This is a virtual constructor for the command. + */ +cmCommand* cmCTestSubmitCommand::Clone() +{ + cmCTestSubmitCommand* ni = new cmCTestSubmitCommand; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; + return ni; +} + cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { const char* submitURL = !this->SubmitURL.empty() @@ -42,33 +64,23 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->Makefile->GetDefinition("CTEST_NOTES_FILES"); if (notesFilesVariable) { std::vector<std::string> notesFiles; - cmCTest::VectorOfStrings newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles); - newNotesFiles.insert(newNotesFiles.end(), notesFiles.begin(), - notesFiles.end()); - this->CTest->GenerateNotesFile(newNotesFiles); + this->CTest->GenerateNotesFile(notesFiles); } const char* extraFilesVariable = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); if (extraFilesVariable) { std::vector<std::string> extraFiles; - cmCTest::VectorOfStrings newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles); - newExtraFiles.insert(newExtraFiles.end(), extraFiles.begin(), - extraFiles.end()); - if (!this->CTest->SubmitExtraFiles(newExtraFiles)) { + if (!this->CTest->SubmitExtraFiles(extraFiles)) { this->SetError("problem submitting extra files."); return nullptr; } } - cmCTestGenericHandler* handler = - this->CTest->GetInitializedHandler("submit"); - if (!handler) { - this->SetError("internal CTest error. Cannot instantiate submit handler"); - return nullptr; - } + cmCTestSubmitHandler* handler = this->CTest->GetSubmitHandler(); + handler->Initialize(); // If no FILES or PARTS given, *all* PARTS are submitted by default. // @@ -90,38 +102,30 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() // But FILES with no PARTS mentioned should just submit the FILES // without any of the default parts. // - std::set<cmCTest::Part> noParts; - static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts); - - static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files); + handler->SelectParts(std::set<cmCTest::Part>()); + handler->SelectFiles(this->Files); } // If a PARTS option was given, select only the named parts for submission. // if (this->PartsMentioned) { - static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts); + handler->SelectParts(this->Parts); } // Pass along any HTTPHEADER to the handler if this option was given. if (!this->HttpHeaders.empty()) { - static_cast<cmCTestSubmitHandler*>(handler)->SetHttpHeaders( - this->HttpHeaders); + handler->SetHttpHeaders(this->HttpHeaders); } - static_cast<cmCTestSubmitHandler*>(handler)->SetOption( - "RetryDelay", this->RetryDelay.c_str()); - static_cast<cmCTestSubmitHandler*>(handler)->SetOption( - "RetryCount", this->RetryCount.c_str()); - static_cast<cmCTestSubmitHandler*>(handler)->SetOption( - "InternalTest", this->InternalTest ? "ON" : "OFF"); + handler->SetOption("RetryDelay", this->RetryDelay.c_str()); + handler->SetOption("RetryCount", this->RetryCount.c_str()); + handler->SetOption("InternalTest", this->InternalTest ? "ON" : "OFF"); handler->SetQuiet(this->Quiet); if (this->CDashUpload) { - static_cast<cmCTestSubmitHandler*>(handler)->SetOption( - "CDashUploadFile", this->CDashUploadFile.c_str()); - static_cast<cmCTestSubmitHandler*>(handler)->SetOption( - "CDashUploadType", this->CDashUploadType.c_str()); + handler->SetOption("CDashUploadFile", this->CDashUploadFile.c_str()); + handler->SetOption("CDashUploadType", this->CDashUploadType.c_str()); } return handler; } @@ -130,7 +134,15 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus& status) { this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD"; - return this->cmCTestHandlerCommand::InitialPass(args, status); + + bool ret = this->cmCTestHandlerCommand::InitialPass(args, status); + + if (this->Values[cts_BUILD_ID] && *this->Values[cts_BUILD_ID]) { + this->Makefile->AddDefinition(this->Values[cts_BUILD_ID], + this->CTest->GetBuildID().c_str()); + } + + return ret; } bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg) diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 0caccd6..1e27046 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -25,26 +25,8 @@ class cmExecutionStatus; class cmCTestSubmitCommand : public cmCTestHandlerCommand { public: - cmCTestSubmitCommand() - { - this->PartsMentioned = false; - this->FilesMentioned = false; - this->InternalTest = false; - this->RetryCount = ""; - this->RetryDelay = ""; - this->CDashUpload = false; - } - - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() override - { - cmCTestSubmitCommand* ni = new cmCTestSubmitCommand; - ni->CTest = this->CTest; - ni->CTestScriptHandler = this->CTestScriptHandler; - return ni; - } + cmCTestSubmitCommand(); + cmCommand* Clone() override; bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus& status) override; @@ -75,11 +57,17 @@ protected: ArgumentDoingLast2 }; + enum + { + cts_BUILD_ID = ct_LAST, + cts_LAST + }; + bool PartsMentioned; std::set<cmCTest::Part> Parts; bool FilesMentioned; bool InternalTest; - cmCTest::SetOfStrings Files; + std::set<std::string> Files; std::string RetryCount; std::string RetryDelay; bool CDashUpload; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 87112da..2b54365 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -259,8 +259,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( upload_as += ctest_curl.Escape(this->CTest->GetCurrentTag()); upload_as += "-"; upload_as += ctest_curl.Escape(this->CTest->GetTestModelString()); - cmCTestScriptHandler* ch = static_cast<cmCTestScriptHandler*>( - this->CTest->GetHandler("script")); + cmCTestScriptHandler* ch = this->CTest->GetScriptHandler(); cmake* cm = ch->GetCMake(); if (cm) { const char* subproject = @@ -343,7 +342,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( if (!chunk.empty()) { cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) + << cmCTestLogWrite(chunk.data(), chunk.size()) << "]" << std::endl, this->Quiet); this->ParseResponse(chunk); @@ -352,7 +351,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( cmCTestOptionalLog( this->CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" + << cmCTestLogWrite(chunkDebug.data(), chunkDebug.size()) << "]" << std::endl, this->Quiet); } @@ -404,12 +403,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( res = ::curl_easy_perform(curl); if (!chunk.empty()) { - cmCTestOptionalLog( - this->CTest, DEBUG, - "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" - << std::endl, - this->Quiet); + cmCTestOptionalLog(this->CTest, DEBUG, + "CURL output: [" + << cmCTestLogWrite(chunk.data(), chunk.size()) + << "]" << std::endl, + this->Quiet); this->ParseResponse(chunk); } @@ -433,11 +431,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( // avoid deref of begin for zero size array if (!chunk.empty()) { *this->LogFile << " Curl output was: " - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) + << cmCTestLogWrite(chunk.data(), chunk.size()) << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << cmCTestLogWrite(chunk.data(), chunk.size()) << "]" << std::endl); } ::curl_easy_cleanup(curl); @@ -486,7 +484,7 @@ void cmCTestSubmitHandler::ParseResponse( if (this->HasWarnings || this->HasErrors) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n"); + << cmCTestLogWrite(chunk.data(), chunk.size()) << "\n"); } } @@ -559,8 +557,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, // has already been uploaded // TODO I added support for subproject. You would need to add // a "&subproject=subprojectname" to the first POST. - cmCTestScriptHandler* ch = - static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script")); + cmCTestScriptHandler* ch = this->CTest->GetScriptHandler(); cmake* cm = ch->GetCMake(); const char* subproject = cm->GetState()->GetGlobalProperty("SubProject"); // TODO: Encode values for a URL instead of trusting caller. @@ -903,7 +900,7 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts) } } -void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files) +void cmCTestSubmitHandler::SelectFiles(std::set<std::string> const& files) { this->Files.insert(files.begin(), files.end()); } diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 58f4f97..e0fed10 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -38,7 +38,7 @@ public: void SelectParts(std::set<cmCTest::Part> const& parts); /** Specify a set of files to submit. */ - void SelectFiles(cmCTest::SetOfStrings const& files); + void SelectFiles(std::set<std::string> const& files); // handle the cdash file upload protocol int HandleCDashUploadFile(std::string const& file, std::string const& type); @@ -74,7 +74,7 @@ private: bool SubmitPart[cmCTest::PartCount]; bool HasWarnings; bool HasErrors; - cmCTest::SetOfStrings Files; + std::set<std::string> Files; std::vector<std::string> HttpHeaders; }; diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 895ca12..cfd5e3d 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -4,6 +4,7 @@ #include "cmCTest.h" #include "cmCTestGenericHandler.h" +#include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -140,5 +141,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler() { - return this->CTest->GetInitializedHandler("test"); + cmCTestTestHandler* handler = this->CTest->GetTestHandler(); + handler->Initialize(); + return handler; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index cf2652a..c9783e4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1486,7 +1486,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) int retVal = 0; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << it << std::endl, this->Quiet); - if (!cmSystemTools::RunSingleCommand(it.c_str(), nullptr, nullptr, &retVal, + if (!cmSystemTools::RunSingleCommand(it, nullptr, nullptr, &retVal, nullptr, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0) { diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 0b557db..17d5f3f 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -11,6 +11,7 @@ #include "cmsys/RegularExpression.hxx" #include <chrono> +#include <cstdint> #include <iosfwd> #include <map> #include <set> @@ -153,7 +154,7 @@ public: std::string Reason; std::string FullCommandLine; cmDuration ExecutionTime; - int ReturnValue; + std::int64_t ReturnValue; int Status; std::string ExceptionStatus; bool CompressOutput; diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 3d800f8..a2f1462 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -3,7 +3,7 @@ #include "cmCTestUpdateCommand.h" #include "cmCTest.h" -#include "cmCTestGenericHandler.h" +#include "cmCTestUpdateHandler.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -74,12 +74,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet); - cmCTestGenericHandler* handler = - this->CTest->GetInitializedHandler("update"); - if (!handler) { - this->SetError("internal CTest error. Cannot instantiate update handler"); - return nullptr; - } + cmCTestUpdateHandler* handler = this->CTest->GetUpdateHandler(); + handler->Initialize(); handler->SetCommand(this); if (source_dir.empty()) { this->SetError("source directory not specified. Please use SOURCE tag"); diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 2fe2cd3..59fbf37 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -6,7 +6,6 @@ #include <vector> #include "cmCTest.h" -#include "cmCTestGenericHandler.h" #include "cmCTestUploadHandler.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -14,14 +13,9 @@ cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() { - cmCTestGenericHandler* handler = - this->CTest->GetInitializedHandler("upload"); - if (!handler) { - this->SetError("internal CTest error. Cannot instantiate upload handler"); - return nullptr; - } - static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files); - + cmCTestUploadHandler* handler = this->CTest->GetUploadHandler(); + handler->Initialize(); + handler->SetFiles(this->Files); handler->SetQuiet(this->Quiet); return handler; } diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 61bf1cc..0d3b06e 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -5,9 +5,9 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmCTest.h" #include "cmCTestHandlerCommand.h" +#include <set> #include <string> class cmCTestGenericHandler; @@ -22,8 +22,6 @@ class cmCommand; class cmCTestUploadCommand : public cmCTestHandlerCommand { public: - cmCTestUploadCommand() {} - /** * This is a virtual constructor for the command. */ @@ -55,7 +53,7 @@ protected: ArgumentDoingLast2 }; - cmCTest::SetOfStrings Files; + std::set<std::string> Files; }; #endif diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx index 261ecab..ee9ee91 100644 --- a/Source/CTest/cmCTestUploadHandler.cxx +++ b/Source/CTest/cmCTestUploadHandler.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestUploadHandler.h" +#include "cmCTest.h" #include "cmGeneratedFileStream.h" #include "cmVersion.h" #include "cmXMLWriter.h" @@ -20,7 +21,7 @@ void cmCTestUploadHandler::Initialize() this->Files.clear(); } -void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files) +void cmCTestUploadHandler::SetFiles(std::set<std::string> const& files) { this->Files = files; } diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h index ff50574..4d8fab4 100644 --- a/Source/CTest/cmCTestUploadHandler.h +++ b/Source/CTest/cmCTestUploadHandler.h @@ -5,9 +5,11 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmCTest.h" #include "cmCTestGenericHandler.h" +#include <set> +#include <string> + /** \class cmCTestUploadHandler * \brief Helper class for CTest * @@ -20,7 +22,6 @@ public: typedef cmCTestGenericHandler Superclass; cmCTestUploadHandler(); - ~cmCTestUploadHandler() override {} /* * The main entry point for this class @@ -30,10 +31,10 @@ public: void Initialize() override; /** Specify a set of files to submit. */ - void SetFiles(cmCTest::SetOfStrings const& files); + void SetFiles(std::set<std::string> const& files); private: - cmCTest::SetOfStrings Files; + std::set<std::string> Files; }; #endif diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 70ef8df..bfe8d70 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -11,7 +11,9 @@ #include <iostream> #include <signal.h> #include <string> -#if !defined(_WIN32) +#if defined(_WIN32) +# include "cm_kwiml.h" +#else # include <unistd.h> #endif #include <utility> @@ -71,7 +73,7 @@ cmProcess::cmProcess(cmCTestRunTest& runner) cmProcess::~cmProcess() = default; -void cmProcess::SetCommand(const char* command) +void cmProcess::SetCommand(std::string const& command) { this->Command = command; } @@ -81,6 +83,11 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args) this->Arguments = args; } +void cmProcess::SetWorkingDirectory(std::string const& dir) +{ + this->WorkingDirectory = dir; +} + bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity) { this->ProcessState = cmProcess::State::Error; @@ -199,7 +206,7 @@ bool cmProcess::Buffer::GetLine(std::string& line) for (size_type sz = this->size(); this->Last != sz; ++this->Last) { if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') { // Extract the range first..last as a line. - const char* text = &*this->begin() + this->First; + const char* text = this->data() + this->First; size_type length = this->Last - this->First; while (length && text[length - 1] == '\r') { length--; @@ -229,7 +236,7 @@ bool cmProcess::Buffer::GetLast(std::string& line) { // Return the partial last line, if any. if (!this->empty()) { - line.assign(&*this->begin(), this->size()); + line.assign(this->data(), this->size()); this->First = this->Last = 0; this->clear(); return true; @@ -353,7 +360,7 @@ void cmProcess::OnExit(int64_t exit_status, int term_signal) } // Record exit information. - this->ExitValue = static_cast<int>(exit_status); + this->ExitValue = exit_status; this->Signal = term_signal; this->TotalTime = std::chrono::steady_clock::now() - this->StartTime; // Because of a processor clock scew the runtime may become slightly @@ -539,7 +546,8 @@ std::string cmProcess::GetExitExceptionString() case STATUS_NO_MEMORY: default: char buf[1024]; - _snprintf(buf, 1024, "Exit code 0x%x\n", this->ExitValue); + const char* fmt = "Exit code 0x%" KWIML_INT_PRIx64 "\n"; + _snprintf(buf, 1024, fmt, this->ExitValue); exception_str.assign(buf); } #else diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index b2d87fa..a0a4b6b 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -28,10 +28,9 @@ class cmProcess public: explicit cmProcess(cmCTestRunTest& runner); ~cmProcess(); - const char* GetCommand() { return this->Command.c_str(); } - void SetCommand(const char* command); + void SetCommand(std::string const& command); void SetCommandArguments(std::vector<std::string> const& arg); - void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; } + void SetWorkingDirectory(std::string const& dir); void SetTimeout(cmDuration t) { this->Timeout = t; } void ChangeTimeout(cmDuration t); void ResetStartTime(); @@ -53,7 +52,7 @@ public: State GetProcessStatus(); int GetId() { return this->Id; } void SetId(int id) { this->Id = id; } - int GetExitValue() { return this->ExitValue; } + int64_t GetExitValue() { return this->ExitValue; } cmDuration GetTotalTime() { return this->TotalTime; } enum class Exception @@ -122,7 +121,7 @@ private: std::vector<std::string> Arguments; std::vector<const char*> ProcessArgs; int Id; - int ExitValue; + int64_t ExitValue; }; #endif |