From f460bbd4c8afab56f93b9831f1f4d8336480fcc5 Mon Sep 17 00:00:00 2001 From: Betsy McPhail Date: Thu, 4 Oct 2018 11:34:27 -0400 Subject: ctest_submit: Refactor file list to use a vector instead of a set Remove duplicates in a way that preserves order. --- Source/CTest/cmCTestSubmitHandler.cxx | 51 ++++++++++++++++++++--------------- Source/CTest/cmCTestSubmitHandler.h | 12 ++++----- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index ecf309a..38b5411 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -12,6 +12,7 @@ #include #include +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestCurl.h" #include "cmCTestScriptHandler.h" @@ -152,10 +153,9 @@ void cmCTestSubmitHandler::Initialize() this->Files.clear(); } -bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, - const std::set& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingFTP( + const std::string& localprefix, const std::vector& files, + const std::string& remoteprefix, const std::string& url) { CURL* curl; CURLcode res; @@ -299,10 +299,9 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, } // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, - const std::set& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingHTTP( + const std::string& localprefix, const std::vector& files, + const std::string& remoteprefix, const std::string& url) { CURL* curl; CURLcode res; @@ -662,9 +661,9 @@ void cmCTestSubmitHandler::ParseResponse( } } -bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::TriggerUsingHTTP( + const std::vector& files, const std::string& remoteprefix, + const std::string& url) { CURL* curl; char error_buffer[1024]; @@ -792,11 +791,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, return true; } -bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, - const std::string& localprefix, - const std::set& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingSCP( + const std::string& scp_command, const std::string& localprefix, + const std::vector& files, const std::string& remoteprefix, + const std::string& url) { if (scp_command.empty() || localprefix.empty() || files.empty() || remoteprefix.empty() || url.empty()) { @@ -890,7 +888,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, } bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& destination) { @@ -925,7 +923,7 @@ bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix, #if defined(CTEST_USE_XMLRPC) bool cmCTestSubmitHandler::SubmitUsingXMLRPC( - const std::string& localprefix, const std::set& files, + const std::string& localprefix, const std::vector& files, const std::string& remoteprefix, const std::string& url) { xmlrpc_env env; @@ -1020,7 +1018,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC( } #else bool cmCTestSubmitHandler::SubmitUsingXMLRPC( - std::string const& /*unused*/, std::set const& /*unused*/, + std::string const& /*unused*/, std::vector const& /*unused*/, std::string const& /*unused*/, std::string const& /*unused*/) { return false; @@ -1351,13 +1349,13 @@ int cmCTestSubmitHandler::ProcessHandler() cmGeneratedFileStream ofs; this->StartLogFile("Submit", ofs); - cmCTest::SetOfStrings files; + std::vector files; std::string prefix = this->GetSubmitResultsPrefix(); if (!this->Files.empty()) { // Submit the explicitly selected files: // - files.insert(this->Files.begin(), this->Files.end()); + files.insert(files.end(), this->Files.begin(), this->Files.end()); } // Add to the list of files to submit from any selected, existing parts: @@ -1404,7 +1402,16 @@ int cmCTestSubmitHandler::ProcessHandler() // Submit files from this part. std::vector const& pfiles = this->CTest->GetSubmitFiles(p); - files.insert(pfiles.begin(), pfiles.end()); + files.insert(files.end(), pfiles.begin(), pfiles.end()); + } + + // Make sure files are unique, but preserve order. + { + // This endPos intermediate is needed to work around non-conformant C++11 + // standard libraries that have erase(iterator,iterator) instead of + // erase(const_iterator,const_iterator). + size_t endPos = cmRemoveDuplicates(files) - files.cbegin(); + files.erase(files.begin() + endPos, files.end()); } if (ofs) { diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index b4d0e77..66f2173 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -57,27 +57,27 @@ private: * Submit file using various ways */ bool SubmitUsingFTP(const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingHTTP(const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingSCP(const std::string& scp_command, const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingCP(const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& url); - bool TriggerUsingHTTP(const std::set& files, + bool TriggerUsingHTTP(const std::vector& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingXMLRPC(const std::string& localprefix, - const std::set& files, + const std::vector& files, const std::string& remoteprefix, const std::string& url); -- cgit v0.12