From b64e59d571e19b0b9e19ba101050a3656caf5934 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 25 Oct 2024 00:50:25 +0200 Subject: [PATCH] cmCTestSubmitHandler: Initialize HttpHeaders with command line --- Source/CTest/cmCTestSubmitHandler.cxx | 1 + Source/CTest/cmCTestSubmitHandler.h | 14 +------------- Source/cmCTest.cxx | 8 +++++++- Source/cmCTest.h | 1 + 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 1cb8135f13..6d18678c41 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -133,6 +133,7 @@ void cmCTestSubmitHandler::Initialize(cmCTest* ctest) this->HTTPProxyAuth.clear(); this->LogFile = nullptr; this->Files.clear(); + this->HttpHeaders = ctest->GetCommandLineHttpHeaders(); } bool cmCTestSubmitHandler::SubmitUsingHTTP( diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index cbfa44d186..0aea5f7816 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -42,20 +42,9 @@ public: // handle the cdash file upload protocol int HandleCDashUploadFile(std::string const& file, std::string const& type); - void AddCommandLineHttpHeader(std::string const& h) - { - this->HttpHeaders.push_back(h); - this->CommandLineHttpHeaders.push_back(h); - } - void SetHttpHeaders(std::vector const& v) { - if (this->CommandLineHttpHeaders.empty()) { - this->HttpHeaders = v; - } else { - this->HttpHeaders = this->CommandLineHttpHeaders; - this->HttpHeaders.insert(this->HttpHeaders.end(), v.begin(), v.end()); - } + this->HttpHeaders.insert(this->HttpHeaders.end(), v.begin(), v.end()); } private: @@ -86,7 +75,6 @@ private: bool HasWarnings; bool HasErrors; std::set Files; - std::vector CommandLineHttpHeaders; std::vector HttpHeaders; bool CDashUpload = false; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 7a08668f19..7d24c6c979 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -206,6 +206,7 @@ struct cmCTest::Private bool NoTestsModeSetInCli = false; cmCTestTestOptions TestOptions; + std::vector CommandLineHttpHeaders; }; struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag) @@ -2497,7 +2498,7 @@ int cmCTest::Run(std::vector const& args) } }, CommandArgument{ "--http-header", CommandArgument::Values::One, [this](std::string const& h) -> bool { - this->Impl->SubmitHandler.AddCommandLineHttpHeader(h); + this->Impl->CommandLineHttpHeaders.push_back(h); return true; } }, CommandArgument{ "--submit-index", CommandArgument::Values::One, @@ -3200,6 +3201,11 @@ cmCTestTestOptions const& cmCTest::GetTestOptions() const return this->Impl->TestOptions; } +std::vector cmCTest::GetCommandLineHttpHeaders() const +{ + return this->Impl->CommandLineHttpHeaders; +} + void cmCTest::AddSubmitFile(Part part, const std::string& name) { this->Impl->Parts[part].SubmitFiles.emplace_back(name); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 4ef3b18618..4e21a62a09 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -445,6 +445,7 @@ public: bool UpdateCTestConfiguration(); cmCTestTestOptions const& GetTestOptions() const; + std::vector GetCommandLineHttpHeaders() const; private: int GenerateNotesFile(cmake* cm, const std::string& files);