diff options
author | Brad King <brad.king@kitware.com> | 2022-06-29 19:53:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-07-05 20:55:40 (GMT) |
commit | 2586afa31bbbbe174ce1dac9549c0d8671ff5567 (patch) | |
tree | 55a83965c51cdafb05702ff6a5ec36a2dd850891 /Source/CTest | |
parent | 5446b15c5c86532573baf831fd41f6240605c6e6 (diff) | |
download | CMake-2586afa31bbbbe174ce1dac9549c0d8671ff5567.zip CMake-2586afa31bbbbe174ce1dac9549c0d8671ff5567.tar.gz CMake-2586afa31bbbbe174ce1dac9549c0d8671ff5567.tar.bz2 |
cmCTest*Command:: Use cm::optional for keyword argument presence
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestCoverageCommand.cxx | 13 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageCommand.h | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestHandlerCommand.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestHandlerCommand.h | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.cxx | 66 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.h | 10 | ||||
-rw-r--r-- | Source/CTest/cmCTestUploadCommand.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestUploadCommand.h | 3 |
8 files changed, 45 insertions, 67 deletions
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 9351b0b..97b0a89 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -4,8 +4,6 @@ #include <set> -#include <cm/string_view> -#include <cmext/algorithm> #include <cmext/string_view> #include "cmCTest.h" @@ -19,13 +17,6 @@ void cmCTestCoverageCommand::BindArguments() this->Bind("LABELS"_s, this->Labels); } -void cmCTestCoverageCommand::CheckArguments( - std::vector<cm::string_view> const& keywords) -{ - this->LabelsMentioned = - !this->Labels.empty() || cm::contains(keywords, "LABELS"_s); -} - cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() { this->CTest->SetCTestConfigurationFromCMakeVariable( @@ -37,9 +28,9 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() handler->Initialize(); // If a LABELS option was given, select only files with the labels. - if (this->LabelsMentioned) { + if (this->Labels) { handler->SetLabelFilter( - std::set<std::string>(this->Labels.begin(), this->Labels.end())); + std::set<std::string>(this->Labels->begin(), this->Labels->end())); } handler->SetQuiet(this->Quiet); diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 20bb1a8..dc8f71e 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -9,7 +9,7 @@ #include <vector> #include <cm/memory> -#include <cm/string_view> +#include <cm/optional> #include "cmCTestHandlerCommand.h" #include "cmCommand.h" @@ -42,9 +42,7 @@ public: protected: void BindArguments() override; - void CheckArguments(std::vector<cm::string_view> const& keywords) override; cmCTestGenericHandler* InitializeHandler() override; - bool LabelsMentioned; - std::vector<std::string> Labels; + cm::optional<std::vector<std::string>> Labels; }; diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 865e27b..af365ad 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -82,11 +82,10 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args, // Process input arguments. std::vector<std::string> unparsedArguments; - std::vector<cm::string_view> keywordsMissingValue; std::vector<cm::string_view> parsedKeywords; - this->Parse(args, &unparsedArguments, &keywordsMissingValue, + this->Parse(args, &unparsedArguments, /*keywordsMissingValue=*/nullptr, &parsedKeywords); - this->CheckArguments(keywordsMissingValue); + this->CheckArguments(); std::sort(parsedKeywords.begin(), parsedKeywords.end()); auto it = std::adjacent_find(parsedKeywords.begin(), parsedKeywords.end()); @@ -243,6 +242,6 @@ void cmCTestHandlerCommand::BindArguments() this->Bind("SUBMIT_INDEX"_s, this->SubmitIndex); } -void cmCTestHandlerCommand::CheckArguments(std::vector<cm::string_view> const&) +void cmCTestHandlerCommand::CheckArguments() { } diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h index 4869deb..31942c8 100644 --- a/Source/CTest/cmCTestHandlerCommand.h +++ b/Source/CTest/cmCTestHandlerCommand.h @@ -7,8 +7,6 @@ #include <string> #include <vector> -#include <cm/string_view> - #include "cmArgumentParser.h" #include "cmCTestCommand.h" @@ -44,7 +42,7 @@ protected: // Command argument handling. virtual void BindArguments(); - virtual void CheckArguments(std::vector<cm::string_view> const& keywords); + virtual void CheckArguments(); bool Append = false; bool Quiet = false; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 288d5b4..a1933cc 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -7,9 +7,7 @@ #include <utility> #include <cm/memory> -#include <cm/string_view> #include <cm/vector> -#include <cmext/algorithm> #include <cmext/string_view> #include "cmCTest.h" @@ -88,7 +86,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() // If FILES are given, but not PARTS, only the FILES are submitted // and *no* PARTS are submitted. // (This is why we select the empty "noParts" set in the - // FilesMentioned block below...) + // if(this->Files) block below...) // // If PARTS are given, only the selected PARTS are submitted. // @@ -97,7 +95,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() // If given explicit FILES to submit, pass them to the handler. // - if (this->FilesMentioned) { + if (this->Files) { // Intentionally select *no* PARTS. (Pass an empty set.) If PARTS // were also explicitly mentioned, they will be selected below... // But FILES with no PARTS mentioned should just submit the FILES @@ -105,14 +103,14 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() // handler->SelectParts(std::set<cmCTest::Part>()); handler->SelectFiles( - std::set<std::string>(this->Files.begin(), this->Files.end())); + std::set<std::string>(this->Files->begin(), this->Files->end())); } // If a PARTS option was given, select only the named parts for submission. // - if (this->PartsMentioned) { + if (this->Parts) { auto parts = - cmMakeRange(this->Parts).transform([this](std::string const& arg) { + cmMakeRange(*(this->Parts)).transform([this](std::string const& arg) { return this->CTest->GetPartFromName(arg); }); handler->SelectParts(std::set<cmCTest::Part>(parts.begin(), parts.end())); @@ -173,33 +171,31 @@ void cmCTestSubmitCommand::BindArguments() this->cmCTestHandlerCommand::BindArguments(); } -void cmCTestSubmitCommand::CheckArguments( - std::vector<cm::string_view> const& keywords) +void cmCTestSubmitCommand::CheckArguments() { - this->PartsMentioned = - !this->Parts.empty() || cm::contains(keywords, "PARTS"_s); - this->FilesMentioned = - !this->Files.empty() || cm::contains(keywords, "FILES"_s); - - cm::erase_if(this->Parts, [this](std::string const& arg) -> bool { - cmCTest::Part p = this->CTest->GetPartFromName(arg); - if (p == cmCTest::PartCount) { - std::ostringstream e; - e << "Part name \"" << arg << "\" is invalid."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return true; - } - return false; - }); - - cm::erase_if(this->Files, [this](std::string const& arg) -> bool { - if (!cmSystemTools::FileExists(arg)) { - std::ostringstream e; - e << "File \"" << arg << "\" does not exist. Cannot submit " - << "a non-existent file."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return true; - } - return false; - }); + if (this->Parts) { + cm::erase_if(*(this->Parts), [this](std::string const& arg) -> bool { + cmCTest::Part p = this->CTest->GetPartFromName(arg); + if (p == cmCTest::PartCount) { + std::ostringstream e; + e << "Part name \"" << arg << "\" is invalid."; + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return true; + } + return false; + }); + } + + if (this->Files) { + cm::erase_if(*(this->Files), [this](std::string const& arg) -> bool { + if (!cmSystemTools::FileExists(arg)) { + std::ostringstream e; + e << "File \"" << arg << "\" does not exist. Cannot submit " + << "a non-existent file."; + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return true; + } + return false; + }); + } } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 65f09c3..903bb64 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -8,7 +8,7 @@ #include <string> #include <vector> -#include <cm/string_view> +#include <cm/optional> #include "cmCTestHandlerCommand.h" @@ -37,13 +37,11 @@ public: protected: void BindArguments() override; - void CheckArguments(std::vector<cm::string_view> const& keywords) override; + void CheckArguments() override; cmCTestGenericHandler* InitializeHandler() override; bool CDashUpload = false; - bool FilesMentioned = false; bool InternalTest = false; - bool PartsMentioned = false; std::string BuildID; std::string CDashUploadFile; @@ -52,7 +50,7 @@ protected: std::string RetryDelay; std::string SubmitURL; - std::vector<std::string> Files; + cm::optional<std::vector<std::string>> Files; std::vector<std::string> HttpHeaders; - std::vector<std::string> Parts; + cm::optional<std::vector<std::string>> Parts; }; diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 8289dad..2ed671c 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -5,7 +5,6 @@ #include <set> #include <sstream> -#include <cm/string_view> #include <cm/vector> #include <cmext/string_view> @@ -22,7 +21,7 @@ void cmCTestUploadCommand::BindArguments() this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError); } -void cmCTestUploadCommand::CheckArguments(std::vector<cm::string_view> const&) +void cmCTestUploadCommand::CheckArguments() { cm::erase_if(this->Files, [this](std::string const& arg) -> bool { if (!cmSystemTools::FileExists(arg)) { diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 0058c31..0dad2bf 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -9,7 +9,6 @@ #include <vector> #include <cm/memory> -#include <cm/string_view> #include "cmCTestHandlerCommand.h" #include "cmCommand.h" @@ -43,7 +42,7 @@ public: protected: void BindArguments() override; - void CheckArguments(std::vector<cm::string_view> const&) override; + void CheckArguments() override; cmCTestGenericHandler* InitializeHandler() override; std::vector<std::string> Files; |