diff options
author | Betsy McPhail <betsy.mcphail@kitware.com> | 2018-10-04 15:34:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-10-10 10:55:05 (GMT) |
commit | f460bbd4c8afab56f93b9831f1f4d8336480fcc5 (patch) | |
tree | 9e53d236ae5e42dd316d4ae1a48b0d3045c1be8f | |
parent | 0abf88f6f618bd08933f8c817f0c4ac07b0bc52c (diff) | |
download | CMake-f460bbd4c8afab56f93b9831f1f4d8336480fcc5.zip CMake-f460bbd4c8afab56f93b9831f1f4d8336480fcc5.tar.gz CMake-f460bbd4c8afab56f93b9831f1f4d8336480fcc5.tar.bz2 |
ctest_submit: Refactor file list to use a vector instead of a set
Remove duplicates in a way that preserves order.
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 51 | ||||
-rw-r--r-- | 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 <stdio.h> #include <stdlib.h> +#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<std::string>& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingFTP( + const std::string& localprefix, const std::vector<std::string>& 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<std::string>& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingHTTP( + const std::string& localprefix, const std::vector<std::string>& 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<std::string>& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::TriggerUsingHTTP( + const std::vector<std::string>& 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<std::string>& files, return true; } -bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, - const std::string& localprefix, - const std::set<std::string>& files, - const std::string& remoteprefix, - const std::string& url) +bool cmCTestSubmitHandler::SubmitUsingSCP( + const std::string& scp_command, const std::string& localprefix, + const std::vector<std::string>& 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<std::string>& files, + const std::vector<std::string>& 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<std::string>& files, + const std::string& localprefix, const std::vector<std::string>& 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<std::string> const& /*unused*/, + std::string const& /*unused*/, std::vector<std::string> 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<std::string> 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<std::string> 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<std::string>& files, + const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingHTTP(const std::string& localprefix, - const std::set<std::string>& files, + const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingSCP(const std::string& scp_command, const std::string& localprefix, - const std::set<std::string>& files, + const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingCP(const std::string& localprefix, - const std::set<std::string>& files, + const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); - bool TriggerUsingHTTP(const std::set<std::string>& files, + bool TriggerUsingHTTP(const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); bool SubmitUsingXMLRPC(const std::string& localprefix, - const std::set<std::string>& files, + const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url); |