Browse Source

Merge topic 'no-stringly-typed-variables'

5497eba1a0 CTestUpdate: Prefer concrete variables over map entries
8cac63814c CTestSubmit: Prefer concrete variables over map entries

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !9935
Brad King 1 year ago
parent
commit
719376b0a6

+ 6 - 5
Source/CTest/cmCTestSubmitCommand.cxx

@@ -164,15 +164,16 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
     handler->SetHttpHeaders(this->HttpHeaders);
   }
 
-  handler->SetOption("RetryDelay", this->RetryDelay);
-  handler->SetOption("RetryCount", this->RetryCount);
-  handler->SetOption("InternalTest", this->InternalTest ? "ON" : "OFF");
+  handler->RetryDelay = this->RetryDelay;
+  handler->RetryCount = this->RetryCount;
+  handler->InternalTest = this->InternalTest;
 
   handler->SetQuiet(this->Quiet);
 
   if (this->CDashUpload) {
-    handler->SetOption("CDashUploadFile", this->CDashUploadFile);
-    handler->SetOption("CDashUploadType", this->CDashUploadType);
+    handler->CDashUpload = true;
+    handler->CDashUploadFile = this->CDashUploadFile;
+    handler->CDashUploadType = this->CDashUploadType;
   }
   return handler;
 }

+ 9 - 10
Source/CTest/cmCTestSubmitHandler.cxx

@@ -283,7 +283,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
 
       upload_as += "&MD5=";
 
-      if (this->GetOption("InternalTest").IsOn()) {
+      if (this->InternalTest) {
         upload_as += "ffffffffffffffffffffffffffffffff";
       } else {
         cmCryptoHash hasher(cmCryptoHash::AlgoMD5);
@@ -365,8 +365,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
       bool successful_submission = response_code == 200;
 
       if (!successful_submission || this->HasErrors) {
-        std::string retryDelay = *this->GetOption("RetryDelay");
-        std::string retryCount = *this->GetOption("RetryCount");
+        std::string retryDelay = this->RetryDelay;
+        std::string retryCount = this->RetryCount;
 
         auto delay = cmDuration(
           retryDelay.empty()
@@ -525,11 +525,11 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
     fields = url.substr(pos + 1);
     url.erase(pos);
   }
-  bool internalTest = this->GetOption("InternalTest").IsOn();
+  bool internalTest = this->InternalTest;
 
   // Get RETRY_COUNT and RETRY_DELAY values if they were set.
-  std::string retryDelayString = *this->GetOption("RetryDelay");
-  std::string retryCountString = *this->GetOption("RetryCount");
+  std::string retryDelayString = this->RetryDelay;
+  std::string retryCountString = this->RetryCount;
   auto retryDelay = std::chrono::seconds(0);
   if (!retryDelayString.empty()) {
     unsigned long retryDelayValue = 0;
@@ -718,10 +718,9 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
 
 int cmCTestSubmitHandler::ProcessHandler()
 {
-  cmValue cdashUploadFile = this->GetOption("CDashUploadFile");
-  cmValue cdashUploadType = this->GetOption("CDashUploadType");
-  if (cdashUploadFile && cdashUploadType) {
-    return this->HandleCDashUploadFile(*cdashUploadFile, *cdashUploadType);
+  if (this->CDashUpload) {
+    return this->HandleCDashUploadFile(this->CDashUploadFile,
+                                       this->CDashUploadType);
   }
 
   const std::string& buildDirectory =

+ 10 - 0
Source/CTest/cmCTestSubmitHandler.h

@@ -88,4 +88,14 @@ private:
   std::set<std::string> Files;
   std::vector<std::string> CommandLineHttpHeaders;
   std::vector<std::string> HttpHeaders;
+
+  bool CDashUpload = false;
+  bool InternalTest = false;
+
+  std::string CDashUploadFile;
+  std::string CDashUploadType;
+  std::string RetryCount;
+  std::string RetryDelay;
+
+  friend class cmCTestSubmitCommand;
 };

+ 1 - 1
Source/CTest/cmCTestUpdateCommand.cxx

@@ -79,7 +79,7 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
     this->SetError("source directory not specified. Please use SOURCE tag");
     return nullptr;
   }
-  handler->SetOption("SourceDirectory", source_dir);
+  handler->SourceDirectory = source_dir;
   handler->SetQuiet(this->Quiet);
   return handler;
 }

+ 4 - 6
Source/CTest/cmCTestUpdateHandler.cxx

@@ -19,7 +19,6 @@
 #include "cmGeneratedFileStream.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
-#include "cmValue.h"
 #include "cmVersion.h"
 #include "cmXMLWriter.h"
 
@@ -109,8 +108,7 @@ int cmCTestUpdateHandler::ProcessHandler()
   static_cast<void>(fixLocale);
 
   // Get source dir
-  cmValue sourceDirectory = this->GetOption("SourceDirectory");
-  if (!sourceDirectory) {
+  if (this->SourceDirectory.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot find SourceDirectory  key in the DartConfiguration.tcl"
                  << std::endl);
@@ -123,7 +121,7 @@ int cmCTestUpdateHandler::ProcessHandler()
   }
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-                     "   Updating the repository: " << *sourceDirectory
+                     "   Updating the repository: " << this->SourceDirectory
                                                     << std::endl,
                      this->Quiet);
 
@@ -163,7 +161,7 @@ int cmCTestUpdateHandler::ProcessHandler()
       break;
   }
   vc->SetCommandLineTool(this->UpdateCommand);
-  vc->SetSourceDirectory(*sourceDirectory);
+  vc->SetSourceDirectory(this->SourceDirectory);
 
   // Cleanup the working tree.
   vc->Cleanup();
@@ -301,7 +299,7 @@ bool cmCTestUpdateHandler::SelectVCS()
   this->UpdateCommand = this->CTest->GetCTestConfiguration("UpdateCommand");
 
   // Detect the VCS managing the source tree.
-  this->UpdateType = this->DetectVCS(this->GetOption("SourceDirectory"));
+  this->UpdateType = this->DetectVCS(this->SourceDirectory);
   if (this->UpdateType == e_UNKNOWN) {
     // The source tree does not have a recognized VCS.  Check the
     // configuration value or command name.

+ 3 - 0
Source/CTest/cmCTestUpdateHandler.h

@@ -59,8 +59,11 @@ private:
 
   // The VCS command to update the working tree.
   std::string UpdateCommand;
+  std::string SourceDirectory;
   int UpdateType;
 
   int DetectVCS(const std::string& dir);
   bool SelectVCS();
+
+  friend class cmCTestUpdateCommand;
 };