Selaa lähdekoodia

CTest: Add function GetSubmitURL

Regina Pfeifer 7 vuotta sitten
vanhempi
sitoutus
65f1fc9d63

+ 2 - 37
Source/CTest/cmCTestSubmitHandler.cxx

@@ -494,23 +494,6 @@ void cmCTestSubmitHandler::ParseResponse(
   }
 }
 
-void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
-                                             std::string& url)
-{
-  dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
-  url = dropMethod;
-  url += "://";
-  if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
-    url += this->CTest->GetCTestConfiguration("DropSiteUser");
-    if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
-      url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
-    }
-    url += "@";
-  }
-  url += this->CTest->GetCTestConfiguration("DropSite") +
-    this->CTest->GetCTestConfiguration("DropLocation");
-}
-
 int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
                                                 std::string const& typeString)
 {
@@ -531,9 +514,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
   curl.SetCurlOptions(args);
   curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
   curl.SetHttpHeaders(this->HttpHeaders);
-  std::string dropMethod;
-  std::string url;
-  this->ConstructCDashURL(dropMethod, url);
+  std::string url = this->CTest->GetSubmitURL();
   std::string fields;
   std::string::size_type pos = url.find('?');
   if (pos != std::string::npos) {
@@ -878,23 +859,7 @@ int cmCTestSubmitHandler::ProcessHandler()
   }
   this->SetLogFile(&ofs);
 
-  std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
-
-  if (dropMethod.empty()) {
-    dropMethod = "http";
-  }
-
-  std::string url = dropMethod;
-  url += "://";
-  if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
-    url += this->CTest->GetCTestConfiguration("DropSiteUser");
-    if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
-      url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
-    }
-    url += "@";
-  }
-  url += this->CTest->GetCTestConfiguration("DropSite") +
-    this->CTest->GetCTestConfiguration("DropLocation");
+  std::string url = this->CTest->GetSubmitURL();
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
                      "   SubmitURL: " << url << '\n', this->Quiet);
   if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +

+ 0 - 2
Source/CTest/cmCTestSubmitHandler.h

@@ -48,8 +48,6 @@ public:
     this->HttpHeaders = v;
   }
 
-  void ConstructCDashURL(std::string& dropMethod, std::string& url);
-
 private:
   void SetLogFile(std::ostream* ost) { this->LogFile = ost; }
 

+ 26 - 0
Source/cmCTest.cxx

@@ -2626,6 +2626,32 @@ void cmCTest::SetCTestConfiguration(const char* name, const char* value,
   this->CTestConfiguration[name] = value;
 }
 
+std::string cmCTest::GetSubmitURL()
+{
+  std::string url;
+  {
+    std::string method = this->GetCTestConfiguration("DropMethod");
+    std::string user = this->GetCTestConfiguration("DropSiteUser");
+    std::string password = this->GetCTestConfiguration("DropSitePassword");
+    std::string site = this->GetCTestConfiguration("DropSite");
+    std::string location = this->GetCTestConfiguration("DropLocation");
+
+    url = method.empty() ? "http" : method;
+    url += "://";
+    if (!user.empty()) {
+      url += user;
+      if (!password.empty()) {
+        url += ':';
+        url += password;
+      }
+      url += '@';
+    }
+    url += site;
+    url += location;
+  }
+  return url;
+}
+
 std::string cmCTest::GetCurrentTag()
 {
   return this->CurrentTag;

+ 2 - 0
Source/cmCTest.h

@@ -176,6 +176,8 @@ public:
                              bool suppress = false);
   void EmptyCTestConfiguration();
 
+  std::string GetSubmitURL();
+
   /**
    * constructor and destructor
    */