浏览代码

cmCTest*Command: Access arguments through an alias

At the top of each function that requires access to arguments,
declare an alias `args = *this`.  Then access all arguments with
`args.` rather than `this->`.  The intention is to make following
changes easier to review.
Daniel Pfeifer 1 年之前
父节点
当前提交
1a2d453b94

+ 19 - 17
Source/CTest/cmCTestBuildCommand.cxx

@@ -41,13 +41,14 @@ void cmCTestBuildCommand::BindArguments()
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler()
 {
+  auto const& args = *this;
   auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest);
 
   cmValue ctestBuildCommand =
     this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
   if (cmNonempty(ctestBuildCommand)) {
     this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand,
-                                       this->Quiet);
+                                       args.Quiet);
   } else {
     cmValue cmakeGeneratorName =
       this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
@@ -59,16 +60,16 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler()
     //
     cmValue ctestBuildConfiguration =
       this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
-    std::string cmakeBuildConfiguration = cmNonempty(this->Configuration)
-      ? this->Configuration
+    std::string cmakeBuildConfiguration = cmNonempty(args.Configuration)
+      ? args.Configuration
       : cmNonempty(ctestBuildConfiguration) ? *ctestBuildConfiguration
                                             : this->CTest->GetConfigType();
 
-    const std::string& cmakeBuildAdditionalFlags = cmNonempty(this->Flags)
-      ? this->Flags
+    const std::string& cmakeBuildAdditionalFlags = cmNonempty(args.Flags)
+      ? args.Flags
       : this->Makefile->GetSafeDefinition("CTEST_BUILD_FLAGS");
-    const std::string& cmakeBuildTarget = cmNonempty(this->Target)
-      ? this->Target
+    const std::string& cmakeBuildTarget = cmNonempty(args.Target)
+      ? args.Target
       : this->Makefile->GetSafeDefinition("CTEST_BUILD_TARGET");
 
     if (cmNonempty(cmakeGeneratorName)) {
@@ -92,13 +93,13 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler()
 
       std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
       std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
-        cmakeBuildTarget, cmakeBuildConfiguration, this->ParallelLevel,
+        cmakeBuildTarget, cmakeBuildConfiguration, args.ParallelLevel,
         cmakeBuildAdditionalFlags, this->Makefile->IgnoreErrorsCMP0061());
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                          "SetMakeCommand:" << buildCommand << "\n",
-                         this->Quiet);
+                         args.Quiet);
       this->CTest->SetCTestConfiguration("MakeCommand", buildCommand,
-                                         this->Quiet);
+                                         args.Quiet);
     } else {
       std::ostringstream ostr;
       /* clang-format off */
@@ -115,29 +116,30 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler()
   if (cmValue useLaunchers =
         this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
     this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers,
-                                       this->Quiet);
+                                       args.Quiet);
   }
 
   if (cmValue labelsForSubprojects =
         this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
     this->CTest->SetCTestConfiguration("LabelsForSubprojects",
-                                       *labelsForSubprojects, this->Quiet);
+                                       *labelsForSubprojects, args.Quiet);
   }
 
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }
 
 void cmCTestBuildCommand::ProcessAdditionalValues(
   cmCTestGenericHandler* generic)
 {
+  auto const& args = *this;
   auto const* handler = static_cast<cmCTestBuildHandler*>(generic);
-  if (!this->NumberErrors.empty()) {
-    this->Makefile->AddDefinition(this->NumberErrors,
+  if (!args.NumberErrors.empty()) {
+    this->Makefile->AddDefinition(args.NumberErrors,
                                   std::to_string(handler->GetTotalErrors()));
   }
-  if (!this->NumberWarnings.empty()) {
-    this->Makefile->AddDefinition(this->NumberWarnings,
+  if (!args.NumberWarnings.empty()) {
+    this->Makefile->AddDefinition(args.NumberWarnings,
                                   std::to_string(handler->GetTotalWarnings()));
   }
 }

+ 7 - 6
Source/CTest/cmCTestConfigureCommand.cxx

@@ -38,10 +38,11 @@ void cmCTestConfigureCommand::BindArguments()
 std::unique_ptr<cmCTestGenericHandler>
 cmCTestConfigureCommand::InitializeHandler()
 {
+  auto const& args = *this;
   cmList options;
 
-  if (!this->Options.empty()) {
-    options.assign(this->Options);
+  if (!args.Options.empty()) {
+    options.assign(args.Options);
   }
 
   if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
@@ -57,7 +58,7 @@ cmCTestConfigureCommand::InitializeHandler()
 
   if (cmNonempty(ctestConfigureCommand)) {
     this->CTest->SetCTestConfiguration("ConfigureCommand",
-                                       *ctestConfigureCommand, this->Quiet);
+                                       *ctestConfigureCommand, args.Quiet);
   } else {
     cmValue cmakeGeneratorName =
       this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
@@ -145,7 +146,7 @@ cmCTestConfigureCommand::InitializeHandler()
       cmakeConfigureCommand += "\"";
 
       this->CTest->SetCTestConfiguration("ConfigureCommand",
-                                         cmakeConfigureCommand, this->Quiet);
+                                         cmakeConfigureCommand, args.Quiet);
     } else {
       this->SetError(
         "Configure command is not specified. If this is a "
@@ -158,10 +159,10 @@ cmCTestConfigureCommand::InitializeHandler()
   if (cmValue labelsForSubprojects =
         this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
     this->CTest->SetCTestConfiguration("LabelsForSubprojects",
-                                       *labelsForSubprojects, this->Quiet);
+                                       *labelsForSubprojects, args.Quiet);
   }
 
   auto handler = cm::make_unique<cmCTestConfigureHandler>(this->CTest);
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }

+ 6 - 5
Source/CTest/cmCTestCoverageCommand.cxx

@@ -29,19 +29,20 @@ void cmCTestCoverageCommand::BindArguments()
 std::unique_ptr<cmCTestGenericHandler>
 cmCTestCoverageCommand::InitializeHandler()
 {
+  auto const& args = *this;
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
+    this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
-    this->Quiet);
+    args.Quiet);
   auto handler = cm::make_unique<cmCTestCoverageHandler>(this->CTest);
 
   // If a LABELS option was given, select only files with the labels.
-  if (this->Labels) {
+  if (args.Labels) {
     handler->SetLabelFilter(
-      std::set<std::string>(this->Labels->begin(), this->Labels->end()));
+      std::set<std::string>(args.Labels->begin(), args.Labels->end()));
   }
 
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }

+ 28 - 27
Source/CTest/cmCTestHandlerCommand.cxx

@@ -71,9 +71,10 @@ private:
 };
 }
 
-bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
-                                        cmExecutionStatus& status)
+bool cmCTestHandlerCommand::InitialPass(
+  std::vector<std::string> const& arguments, cmExecutionStatus& status)
 {
+  auto& args = *this;
   // save error state and restore it if needed
   SaveRestoreErrorState errorState;
   // Allocate space for argument values.
@@ -81,13 +82,13 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
 
   // Process input arguments.
   std::vector<std::string> unparsedArguments;
-  this->Parse(args, &unparsedArguments);
+  this->Parse(arguments, &unparsedArguments);
   this->CheckArguments();
 
-  std::sort(this->ParsedKeywords.begin(), this->ParsedKeywords.end());
-  auto it = std::adjacent_find(this->ParsedKeywords.begin(),
-                               this->ParsedKeywords.end());
-  if (it != this->ParsedKeywords.end()) {
+  std::sort(args.ParsedKeywords.begin(), args.ParsedKeywords.end());
+  auto it =
+    std::adjacent_find(args.ParsedKeywords.begin(), args.ParsedKeywords.end());
+  if (it != args.ParsedKeywords.end()) {
     this->Makefile->IssueMessage(
       MessageType::FATAL_ERROR,
       cmStrCat("Called with more than one value for ", *it));
@@ -98,7 +99,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     this->SetError(cmStrCat("called with unknown argument \"",
                             unparsedArguments.front(), "\"."));
   }
-  bool const captureCMakeError = !this->CaptureCMakeError.empty();
+  bool const captureCMakeError = !args.CaptureCMakeError.empty();
   // now that arguments are parsed check to see if there is a
   // CAPTURE_CMAKE_ERROR specified let the errorState object know.
   if (captureCMakeError) {
@@ -108,7 +109,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
   if (foundBadArgument) {
     // store the cmake error
     if (captureCMakeError) {
-      this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+      this->Makefile->AddDefinition(args.CaptureCMakeError, "-1");
       std::string const err = this->GetName() + " " + status.GetError();
       if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
@@ -130,37 +131,37 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     this->CTest->SetConfigType(*ctestConfigType);
   }
 
-  if (!this->Build.empty()) {
+  if (!args.Build.empty()) {
     this->CTest->SetCTestConfiguration(
-      "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build),
-      this->Quiet);
+      "BuildDirectory", cmSystemTools::CollapseFullPath(args.Build),
+      args.Quiet);
   } else {
     std::string const& bdir =
       this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
     if (!bdir.empty()) {
       this->CTest->SetCTestConfiguration(
-        "BuildDirectory", cmSystemTools::CollapseFullPath(bdir), this->Quiet);
+        "BuildDirectory", cmSystemTools::CollapseFullPath(bdir), args.Quiet);
     } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "CTEST_BINARY_DIRECTORY not set" << std::endl);
     }
   }
-  if (!this->Source.empty()) {
+  if (!args.Source.empty()) {
     cmCTestLog(this->CTest, DEBUG,
-               "Set source directory to: " << this->Source << std::endl);
+               "Set source directory to: " << args.Source << std::endl);
     this->CTest->SetCTestConfiguration(
-      "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source),
-      this->Quiet);
+      "SourceDirectory", cmSystemTools::CollapseFullPath(args.Source),
+      args.Quiet);
   } else {
     this->CTest->SetCTestConfiguration(
       "SourceDirectory",
       cmSystemTools::CollapseFullPath(
         this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")),
-      this->Quiet);
+      args.Quiet);
   }
 
   if (cmValue changeId = this->Makefile->GetDefinition("CTEST_CHANGE_ID")) {
-    this->CTest->SetCTestConfiguration("ChangeId", *changeId, this->Quiet);
+    this->CTest->SetCTestConfiguration("ChangeId", *changeId, args.Quiet);
   }
 
   cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl);
@@ -170,7 +171,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
                "Cannot instantiate test handler " << this->GetName()
                                                   << std::endl);
     if (captureCMakeError) {
-      this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+      this->Makefile->AddDefinition(args.CaptureCMakeError, "-1");
       std::string const& err = status.GetError();
       if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
@@ -180,18 +181,18 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     return false;
   }
 
-  handler->SetAppendXML(this->Append);
+  handler->SetAppendXML(args.Append);
 
   handler->PopulateCustomVectors(this->Makefile);
-  if (!this->SubmitIndex.empty()) {
-    handler->SetSubmitIndex(atoi(this->SubmitIndex.c_str()));
+  if (!args.SubmitIndex.empty()) {
+    handler->SetSubmitIndex(atoi(args.SubmitIndex.c_str()));
   }
   cmWorkingDirectory workdir(
     this->CTest->GetCTestConfiguration("BuildDirectory"));
   if (workdir.Failed()) {
     this->SetError(workdir.GetError());
     if (captureCMakeError) {
-      this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+      this->Makefile->AddDefinition(args.CaptureCMakeError, "-1");
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  this->GetName() << " " << status.GetError() << "\n");
       // return success because failure is recorded in CAPTURE_CMAKE_ERROR
@@ -205,8 +206,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
   handler->SetCMakeInstance(this->Makefile->GetCMakeInstance());
 
   int res = handler->ProcessHandler();
-  if (!this->ReturnValue.empty()) {
-    this->Makefile->AddDefinition(this->ReturnValue, std::to_string(res));
+  if (!args.ReturnValue.empty()) {
+    this->Makefile->AddDefinition(args.ReturnValue, std::to_string(res));
   }
   this->ProcessAdditionalValues(handler.get());
   // log the error message if there was an error
@@ -222,7 +223,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
       }
     }
     // store the captured cmake error state 0 or -1
-    this->Makefile->AddDefinition(this->CaptureCMakeError, returnString);
+    this->Makefile->AddDefinition(args.CaptureCMakeError, returnString);
   }
   return true;
 }

+ 10 - 8
Source/CTest/cmCTestMemCheckCommand.cxx

@@ -29,33 +29,35 @@ void cmCTestMemCheckCommand::BindArguments()
 std::unique_ptr<cmCTestTestHandler>
 cmCTestMemCheckCommand::InitializeActualHandler()
 {
+  auto const& args = *this;
   auto handler = cm::make_unique<cmCTestMemCheckHandler>(this->CTest);
 
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
+    this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "MemoryCheckSanitizerOptions",
-    "CTEST_MEMORYCHECK_SANITIZER_OPTIONS", this->Quiet);
+    "CTEST_MEMORYCHECK_SANITIZER_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "MemoryCheckCommandOptions",
-    "CTEST_MEMORYCHECK_COMMAND_OPTIONS", this->Quiet);
+    "CTEST_MEMORYCHECK_COMMAND_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "MemoryCheckSuppressionFile",
-    "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", this->Quiet);
+    "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", args.Quiet);
 
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestTestHandler>(std::move(handler));
 }
 
 void cmCTestMemCheckCommand::ProcessAdditionalValues(
   cmCTestGenericHandler* handler)
 {
-  if (!this->DefectCount.empty()) {
+  auto const& args = *this;
+  if (!args.DefectCount.empty()) {
     this->Makefile->AddDefinition(
-      this->DefectCount,
+      args.DefectCount,
       std::to_string(
         static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount()));
   }

+ 42 - 39
Source/CTest/cmCTestSubmitCommand.cxx

@@ -33,75 +33,76 @@ std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
 std::unique_ptr<cmCTestGenericHandler>
 cmCTestSubmitCommand::InitializeHandler()
 {
-  cmValue submitURL = !this->SubmitURL.empty()
-    ? cmValue(this->SubmitURL)
+  auto const& args = *this;
+  cmValue submitURL = !args.SubmitURL.empty()
+    ? cmValue(args.SubmitURL)
     : this->Makefile->GetDefinition("CTEST_SUBMIT_URL");
 
   if (submitURL) {
-    this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, this->Quiet);
+    this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, args.Quiet);
   } else {
     this->CTest->SetCTestConfigurationFromCMakeVariable(
-      this->Makefile, "DropMethod", "CTEST_DROP_METHOD", this->Quiet);
+      this->Makefile, "DropMethod", "CTEST_DROP_METHOD", args.Quiet);
     this->CTest->SetCTestConfigurationFromCMakeVariable(
-      this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
+      this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", args.Quiet);
     this->CTest->SetCTestConfigurationFromCMakeVariable(
       this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
-      this->Quiet);
+      args.Quiet);
     this->CTest->SetCTestConfigurationFromCMakeVariable(
-      this->Makefile, "DropSite", "CTEST_DROP_SITE", this->Quiet);
+      this->Makefile, "DropSite", "CTEST_DROP_SITE", args.Quiet);
     this->CTest->SetCTestConfigurationFromCMakeVariable(
-      this->Makefile, "DropLocation", "CTEST_DROP_LOCATION", this->Quiet);
+      this->Makefile, "DropLocation", "CTEST_DROP_LOCATION", args.Quiet);
   }
 
   if (!this->CTest->SetCTestConfigurationFromCMakeVariable(
-        this->Makefile, "TLSVersion", "CTEST_TLS_VERSION", this->Quiet)) {
+        this->Makefile, "TLSVersion", "CTEST_TLS_VERSION", args.Quiet)) {
     if (cmValue tlsVersionVar =
           this->Makefile->GetDefinition("CMAKE_TLS_VERSION")) {
       cmCTestOptionalLog(
         this->CTest, HANDLER_VERBOSE_OUTPUT,
         "SetCTestConfiguration from CMAKE_TLS_VERSION:TLSVersion:"
           << *tlsVersionVar << std::endl,
-        this->Quiet);
+        args.Quiet);
       this->CTest->SetCTestConfiguration("TLSVersion", *tlsVersionVar,
-                                         this->Quiet);
+                                         args.Quiet);
     } else if (cm::optional<std::string> tlsVersionEnv =
                  cmSystemTools::GetEnvVar("CMAKE_TLS_VERSION")) {
       cmCTestOptionalLog(
         this->CTest, HANDLER_VERBOSE_OUTPUT,
         "SetCTestConfiguration from ENV{CMAKE_TLS_VERSION}:TLSVersion:"
           << *tlsVersionEnv << std::endl,
-        this->Quiet);
+        args.Quiet);
       this->CTest->SetCTestConfiguration("TLSVersion", *tlsVersionEnv,
-                                         this->Quiet);
+                                         args.Quiet);
     }
   }
   if (!this->CTest->SetCTestConfigurationFromCMakeVariable(
-        this->Makefile, "TLSVerify", "CTEST_TLS_VERIFY", this->Quiet)) {
+        this->Makefile, "TLSVerify", "CTEST_TLS_VERIFY", args.Quiet)) {
     if (cmValue tlsVerifyVar =
           this->Makefile->GetDefinition("CMAKE_TLS_VERIFY")) {
       cmCTestOptionalLog(
         this->CTest, HANDLER_VERBOSE_OUTPUT,
         "SetCTestConfiguration from CMAKE_TLS_VERIFY:TLSVerify:"
           << *tlsVerifyVar << std::endl,
-        this->Quiet);
+        args.Quiet);
       this->CTest->SetCTestConfiguration("TLSVerify", *tlsVerifyVar,
-                                         this->Quiet);
+                                         args.Quiet);
     } else if (cm::optional<std::string> tlsVerifyEnv =
                  cmSystemTools::GetEnvVar("CMAKE_TLS_VERIFY")) {
       cmCTestOptionalLog(
         this->CTest, HANDLER_VERBOSE_OUTPUT,
         "SetCTestConfiguration from ENV{CMAKE_TLS_VERIFY}:TLSVerify:"
           << *tlsVerifyEnv << std::endl,
-        this->Quiet);
+        args.Quiet);
       this->CTest->SetCTestConfiguration("TLSVerify", *tlsVerifyEnv,
-                                         this->Quiet);
+                                         args.Quiet);
     }
   }
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
+    this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "SubmitInactivityTimeout",
-    "CTEST_SUBMIT_INACTIVITY_TIMEOUT", this->Quiet);
+    "CTEST_SUBMIT_INACTIVITY_TIMEOUT", args.Quiet);
 
   cmValue notesFilesVariable =
     this->Makefile->GetDefinition("CTEST_NOTES_FILES");
@@ -128,7 +129,7 @@ cmCTestSubmitCommand::InitializeHandler()
   // If FILES are given, but not PARTS, only the FILES are submitted
   // and *no* PARTS are submitted.
   //  (This is why we select the empty "noParts" set in the
-  //   if(this->Files) block below...)
+  //   if(args.Files) block below...)
   //
   // If PARTS are given, only the selected PARTS are submitted.
   //
@@ -137,7 +138,7 @@ cmCTestSubmitCommand::InitializeHandler()
 
   // If given explicit FILES to submit, pass them to the handler.
   //
-  if (this->Files) {
+  if (args.Files) {
     // Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
     // were also explicitly mentioned, they will be selected below...
     // But FILES with no PARTS mentioned should just submit the FILES
@@ -145,34 +146,34 @@ cmCTestSubmitCommand::InitializeHandler()
     //
     handler->SelectParts(std::set<cmCTest::Part>());
     handler->SelectFiles(
-      std::set<std::string>(this->Files->begin(), this->Files->end()));
+      std::set<std::string>(args.Files->begin(), args.Files->end()));
   }
 
   // If a PARTS option was given, select only the named parts for submission.
   //
-  if (this->Parts) {
+  if (args.Parts) {
     auto parts =
-      cmMakeRange(*(this->Parts)).transform([this](std::string const& arg) {
+      cmMakeRange(*(args.Parts)).transform([this](std::string const& arg) {
         return this->CTest->GetPartFromName(arg);
       });
     handler->SelectParts(std::set<cmCTest::Part>(parts.begin(), parts.end()));
   }
 
   // Pass along any HTTPHEADER to the handler if this option was given.
-  if (!this->HttpHeaders.empty()) {
-    handler->SetHttpHeaders(this->HttpHeaders);
+  if (!args.HttpHeaders.empty()) {
+    handler->SetHttpHeaders(args.HttpHeaders);
   }
 
-  handler->RetryDelay = this->RetryDelay;
-  handler->RetryCount = this->RetryCount;
-  handler->InternalTest = this->InternalTest;
+  handler->RetryDelay = args.RetryDelay;
+  handler->RetryCount = args.RetryCount;
+  handler->InternalTest = args.InternalTest;
 
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
 
   if (this->CDashUpload) {
     handler->CDashUpload = true;
-    handler->CDashUploadFile = this->CDashUploadFile;
-    handler->CDashUploadType = this->CDashUploadType;
+    handler->CDashUploadFile = args.CDashUploadFile;
+    handler->CDashUploadType = args.CDashUploadType;
   }
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }
@@ -210,8 +211,9 @@ void cmCTestSubmitCommand::BindArguments()
 
 void cmCTestSubmitCommand::CheckArguments()
 {
-  if (this->Parts) {
-    cm::erase_if(*(this->Parts), [this](std::string const& arg) -> bool {
+  auto& args = *this;
+  if (args.Parts) {
+    cm::erase_if(*(args.Parts), [this](std::string const& arg) -> bool {
       cmCTest::Part p = this->CTest->GetPartFromName(arg);
       if (p == cmCTest::PartCount) {
         std::ostringstream e;
@@ -223,8 +225,8 @@ void cmCTestSubmitCommand::CheckArguments()
     });
   }
 
-  if (this->Files) {
-    cm::erase_if(*(this->Files), [this](std::string const& arg) -> bool {
+  if (args.Files) {
+    cm::erase_if(*(args.Files), [this](std::string const& arg) -> bool {
       if (!cmSystemTools::FileExists(arg)) {
         std::ostringstream e;
         e << "File \"" << arg << "\" does not exist. Cannot submit "
@@ -239,7 +241,8 @@ void cmCTestSubmitCommand::CheckArguments()
 
 void cmCTestSubmitCommand::ProcessAdditionalValues(cmCTestGenericHandler*)
 {
-  if (!this->BuildID.empty()) {
-    this->Makefile->AddDefinition(this->BuildID, this->CTest->GetBuildID());
+  auto const& args = *this;
+  if (!args.BuildID.empty()) {
+    this->Makefile->AddDefinition(args.BuildID, this->CTest->GetBuildID());
   }
 }

+ 41 - 41
Source/CTest/cmCTestTestCommand.cxx

@@ -55,6 +55,7 @@ void cmCTestTestCommand::BindArguments()
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler()
 {
+  auto& args = *this;
   cmValue ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
 
   cmDuration timeout;
@@ -71,65 +72,64 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler()
 
   cmValue resourceSpecFile =
     this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE");
-  if (this->ResourceSpecFile.empty() && resourceSpecFile) {
-    this->ResourceSpecFile = *resourceSpecFile;
+  if (args.ResourceSpecFile.empty() && resourceSpecFile) {
+    args.ResourceSpecFile = *resourceSpecFile;
   }
 
   auto handler = this->InitializeActualHandler();
-  if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) {
+  if (!args.Start.empty() || !args.End.empty() || !args.Stride.empty()) {
     handler->TestOptions.TestsToRunInformation =
-      cmStrCat(this->Start, ',', this->End, ',', this->Stride);
+      cmStrCat(args.Start, ',', args.End, ',', args.Stride);
   }
-  if (!this->Exclude.empty()) {
-    handler->TestOptions.ExcludeRegularExpression = this->Exclude;
+  if (!args.Exclude.empty()) {
+    handler->TestOptions.ExcludeRegularExpression = args.Exclude;
   }
-  if (!this->Include.empty()) {
-    handler->TestOptions.IncludeRegularExpression = this->Include;
+  if (!args.Include.empty()) {
+    handler->TestOptions.IncludeRegularExpression = args.Include;
   }
-  if (!this->ExcludeLabel.empty()) {
+  if (!args.ExcludeLabel.empty()) {
     handler->TestOptions.ExcludeLabelRegularExpression.push_back(
-      this->ExcludeLabel);
+      args.ExcludeLabel);
   }
-  if (!this->IncludeLabel.empty()) {
-    handler->TestOptions.LabelRegularExpression.push_back(this->IncludeLabel);
+  if (!args.IncludeLabel.empty()) {
+    handler->TestOptions.LabelRegularExpression.push_back(args.IncludeLabel);
   }
 
-  if (!this->ExcludeTestsFromFile.empty()) {
-    handler->TestOptions.ExcludeTestListFile = this->ExcludeTestsFromFile;
+  if (!args.ExcludeTestsFromFile.empty()) {
+    handler->TestOptions.ExcludeTestListFile = args.ExcludeTestsFromFile;
   }
-  if (!this->IncludeTestsFromFile.empty()) {
-    handler->TestOptions.TestListFile = this->IncludeTestsFromFile;
+  if (!args.IncludeTestsFromFile.empty()) {
+    handler->TestOptions.TestListFile = args.IncludeTestsFromFile;
   }
 
-  if (!this->ExcludeFixture.empty()) {
-    handler->TestOptions.ExcludeFixtureRegularExpression =
-      this->ExcludeFixture;
+  if (!args.ExcludeFixture.empty()) {
+    handler->TestOptions.ExcludeFixtureRegularExpression = args.ExcludeFixture;
   }
-  if (!this->ExcludeFixtureSetup.empty()) {
+  if (!args.ExcludeFixtureSetup.empty()) {
     handler->TestOptions.ExcludeFixtureSetupRegularExpression =
-      this->ExcludeFixtureSetup;
+      args.ExcludeFixtureSetup;
   }
-  if (!this->ExcludeFixtureCleanup.empty()) {
+  if (!args.ExcludeFixtureCleanup.empty()) {
     handler->TestOptions.ExcludeFixtureCleanupRegularExpression =
-      this->ExcludeFixtureCleanup;
+      args.ExcludeFixtureCleanup;
   }
-  if (this->StopOnFailure) {
+  if (args.StopOnFailure) {
     handler->TestOptions.StopOnFailure = true;
   }
-  if (this->ParallelLevel) {
-    handler->ParallelLevel = *this->ParallelLevel;
+  if (args.ParallelLevel) {
+    handler->ParallelLevel = *args.ParallelLevel;
   }
-  if (!this->Repeat.empty()) {
-    handler->Repeat = this->Repeat;
+  if (!args.Repeat.empty()) {
+    handler->Repeat = args.Repeat;
   }
-  if (!this->ScheduleRandom.empty()) {
-    handler->TestOptions.ScheduleRandom = cmValue(this->ScheduleRandom).IsOn();
+  if (!args.ScheduleRandom.empty()) {
+    handler->TestOptions.ScheduleRandom = cmValue(args.ScheduleRandom).IsOn();
   }
-  if (!this->ResourceSpecFile.empty()) {
-    handler->TestOptions.ResourceSpecFile = this->ResourceSpecFile;
+  if (!args.ResourceSpecFile.empty()) {
+    handler->TestOptions.ResourceSpecFile = args.ResourceSpecFile;
   }
-  if (!this->StopTime.empty()) {
-    this->CTest->SetStopTime(this->StopTime);
+  if (!args.StopTime.empty()) {
+    this->CTest->SetStopTime(args.StopTime);
   }
 
   // Test load is determined by: TEST_LOAD argument,
@@ -137,11 +137,11 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler()
   // command line argument... in that order.
   unsigned long testLoad;
   cmValue ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
-  if (!this->TestLoad.empty()) {
-    if (!cmStrToULong(this->TestLoad, &testLoad)) {
+  if (!args.TestLoad.empty()) {
+    if (!cmStrToULong(args.TestLoad, &testLoad)) {
       testLoad = 0;
       cmCTestLog(this->CTest, WARNING,
-                 "Invalid value for 'TEST_LOAD' : " << this->TestLoad
+                 "Invalid value for 'TEST_LOAD' : " << args.TestLoad
                                                     << std::endl);
     }
   } else if (cmNonempty(ctestTestLoad)) {
@@ -159,14 +159,14 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler()
   if (cmValue labelsForSubprojects =
         this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
     this->CTest->SetCTestConfiguration("LabelsForSubprojects",
-                                       *labelsForSubprojects, this->Quiet);
+                                       *labelsForSubprojects, args.Quiet);
   }
 
-  if (!this->OutputJUnit.empty()) {
-    handler->SetJUnitXMLFileName(this->OutputJUnit);
+  if (!args.OutputJUnit.empty()) {
+    handler->SetJUnitXMLFileName(args.OutputJUnit);
   }
 
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }
 

+ 27 - 26
Source/CTest/cmCTestUpdateCommand.cxx

@@ -23,69 +23,70 @@ std::unique_ptr<cmCommand> cmCTestUpdateCommand::Clone()
 std::unique_ptr<cmCTestGenericHandler>
 cmCTestUpdateCommand::InitializeHandler()
 {
-  if (!this->Source.empty()) {
+  auto const& args = *this;
+  if (!args.Source.empty()) {
     this->CTest->SetCTestConfiguration(
-      "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source),
-      this->Quiet);
+      "SourceDirectory", cmSystemTools::CollapseFullPath(args.Source),
+      args.Quiet);
   } else {
     this->CTest->SetCTestConfiguration(
       "SourceDirectory",
       cmSystemTools::CollapseFullPath(
         this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")),
-      this->Quiet);
+      args.Quiet);
   }
   std::string source_dir =
     this->CTest->GetCTestConfiguration("SourceDirectory");
 
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
+    this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
+    this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
+    this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
+    this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
+    this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
+    this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
+    this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
+    this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     this->Makefile, "UpdateVersionOverride", "CTEST_UPDATE_VERSION_OVERRIDE",
-    this->Quiet);
+    args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
+    this->Makefile, "HGCommand", "CTEST_HG_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
+    this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "P4Command", "CTEST_P4_COMMAND", this->Quiet);
+    this->Makefile, "P4Command", "CTEST_P4_COMMAND", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
+    this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "P4Client", "CTEST_P4_CLIENT", this->Quiet);
+    this->Makefile, "P4Client", "CTEST_P4_CLIENT", args.Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
+    this->Makefile, "P4Options", "CTEST_P4_OPTIONS", args.Quiet);
 
   auto handler = cm::make_unique<cmCTestUpdateHandler>(this->CTest);
   if (source_dir.empty()) {
@@ -93,6 +94,6 @@ cmCTestUpdateCommand::InitializeHandler()
     return nullptr;
   }
   handler->SourceDirectory = source_dir;
-  handler->SetQuiet(this->Quiet);
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }

+ 5 - 3
Source/CTest/cmCTestUploadCommand.cxx

@@ -33,7 +33,8 @@ void cmCTestUploadCommand::BindArguments()
 
 void cmCTestUploadCommand::CheckArguments()
 {
-  cm::erase_if(this->Files, [this](std::string const& arg) -> bool {
+  auto& args = *this;
+  cm::erase_if(args.Files, [this](std::string const& arg) -> bool {
     if (!cmSystemTools::FileExists(arg)) {
       std::ostringstream e;
       e << "File \"" << arg << "\" does not exist. Cannot submit "
@@ -48,9 +49,10 @@ void cmCTestUploadCommand::CheckArguments()
 std::unique_ptr<cmCTestGenericHandler>
 cmCTestUploadCommand::InitializeHandler()
 {
+  auto const& args = *this;
   auto handler = cm::make_unique<cmCTestUploadHandler>(this->CTest);
   handler->SetFiles(
-    std::set<std::string>(this->Files.begin(), this->Files.end()));
-  handler->SetQuiet(this->Quiet);
+    std::set<std::string>(args.Files.begin(), args.Files.end()));
+  handler->SetQuiet(args.Quiet);
   return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
 }