diff options
author | Brad King <brad.king@kitware.com> | 2021-09-16 12:20:09 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-09-16 12:20:30 (GMT) |
commit | 9858381ba8ed8a332169e2d0b3a2ce54fdd51712 (patch) | |
tree | 6718d0aafe7d170e4af0ce434938647bda3696b3 | |
parent | 98f78af88b253de8762f6238f35f09c4079840c0 (diff) | |
parent | 8f5245168268c99f78074cde24f9dfe75cfaea93 (diff) | |
download | CMake-9858381ba8ed8a332169e2d0b3a2ce54fdd51712.zip CMake-9858381ba8ed8a332169e2d0b3a2ce54fdd51712.tar.gz CMake-9858381ba8ed8a332169e2d0b3a2ce54fdd51712.tar.bz2 |
Merge topic 'enh-CTest-SetOption-accepts-new-types'
8f52451682 Use new SetOption signatures
8d0ae460de cmCTestGenericHandler::SetOption accepts cmProp or std::string
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6525
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.cxx | 26 | ||||
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.h | 10 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestCommand.cxx | 20 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateCommand.cxx | 2 |
5 files changed, 49 insertions, 17 deletions
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index bd33055..dc7103a 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -21,11 +21,12 @@ cmCTestGenericHandler::cmCTestGenericHandler() cmCTestGenericHandler::~cmCTestGenericHandler() = default; +namespace { /* Modify the given `map`, setting key `op` to `value` if `value` * is non-null, otherwise removing key `op` (if it exists). */ -static void SetMapValue(cmCTestGenericHandler::t_StringToString& map, - const std::string& op, const char* value) +void SetMapValue(cmCTestGenericHandler::t_StringToString& map, + const std::string& op, const char* value) { if (!value) { map.erase(op); @@ -34,11 +35,26 @@ static void SetMapValue(cmCTestGenericHandler::t_StringToString& map, map[op] = value; } +void SetMapValue(cmCTestGenericHandler::t_StringToString& map, + const std::string& op, cmProp value) +{ + if (!value) { + map.erase(op); + return; + } + + map[op] = *value; +} +} void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { SetMapValue(this->Options, op, value); } +void cmCTestGenericHandler::SetOption(const std::string& op, cmProp value) +{ + SetMapValue(this->Options, op, value); +} void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) @@ -46,6 +62,12 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op, this->SetOption(op, value); SetMapValue(this->PersistentOptions, op, value); } +void cmCTestGenericHandler::SetPersistentOption(const std::string& op, + cmProp value) +{ + this->SetOption(op, value); + SetMapValue(this->PersistentOptions, op, value); +} void cmCTestGenericHandler::AddMultiOption(const std::string& op, const std::string& value) diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 0b8b224..852d4ea 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -87,7 +87,17 @@ public: * as a multi-value will return nullptr. */ void SetPersistentOption(const std::string& op, const char* value); + void SetPersistentOption(const std::string& op, const std::string& value) + { + this->SetPersistentOption(op, cmProp(value)); + } + void SetPersistentOption(const std::string& op, cmProp value); void SetOption(const std::string& op, const char* value); + void SetOption(const std::string& op, const std::string& value) + { + this->SetOption(op, cmProp(value)); + } + void SetOption(const std::string& op, cmProp value); cmProp GetOption(const std::string& op); /** diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 7aeb288..6824752 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -119,15 +119,15 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() handler->SetHttpHeaders(this->HttpHeaders); } - handler->SetOption("RetryDelay", this->RetryDelay.c_str()); - handler->SetOption("RetryCount", this->RetryCount.c_str()); + handler->SetOption("RetryDelay", this->RetryDelay); + handler->SetOption("RetryCount", this->RetryCount); handler->SetOption("InternalTest", this->InternalTest ? "ON" : "OFF"); handler->SetQuiet(this->Quiet); if (this->CDashUpload) { - handler->SetOption("CDashUploadFile", this->CDashUploadFile.c_str()); - handler->SetOption("CDashUploadType", this->CDashUploadType.c_str()); + handler->SetOption("CDashUploadFile", this->CDashUploadFile); + handler->SetOption("CDashUploadType", this->CDashUploadType); } return handler; } diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 67f4986..80b8d4f 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -64,13 +64,13 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) { handler->SetOption( "TestsToRunInformation", - cmStrCat(this->Start, ',', this->End, ',', this->Stride).c_str()); + cmStrCat(this->Start, ',', this->End, ',', this->Stride)); } if (!this->Exclude.empty()) { - handler->SetOption("ExcludeRegularExpression", this->Exclude.c_str()); + handler->SetOption("ExcludeRegularExpression", this->Exclude); } if (!this->Include.empty()) { - handler->SetOption("IncludeRegularExpression", this->Include.c_str()); + handler->SetOption("IncludeRegularExpression", this->Include); } if (!this->ExcludeLabel.empty()) { handler->AddMultiOption("ExcludeLabelRegularExpression", @@ -81,30 +81,30 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } if (!this->ExcludeFixture.empty()) { handler->SetOption("ExcludeFixtureRegularExpression", - this->ExcludeFixture.c_str()); + this->ExcludeFixture); } if (!this->ExcludeFixtureSetup.empty()) { handler->SetOption("ExcludeFixtureSetupRegularExpression", - this->ExcludeFixtureSetup.c_str()); + this->ExcludeFixtureSetup); } if (!this->ExcludeFixtureCleanup.empty()) { handler->SetOption("ExcludeFixtureCleanupRegularExpression", - this->ExcludeFixtureCleanup.c_str()); + this->ExcludeFixtureCleanup); } if (this->StopOnFailure) { handler->SetOption("StopOnFailure", "ON"); } if (!this->ParallelLevel.empty()) { - handler->SetOption("ParallelLevel", this->ParallelLevel.c_str()); + handler->SetOption("ParallelLevel", this->ParallelLevel); } if (!this->Repeat.empty()) { - handler->SetOption("Repeat", this->Repeat.c_str()); + handler->SetOption("Repeat", this->Repeat); } if (!this->ScheduleRandom.empty()) { - handler->SetOption("ScheduleRandom", this->ScheduleRandom.c_str()); + handler->SetOption("ScheduleRandom", this->ScheduleRandom); } if (!this->ResourceSpecFile.empty()) { - handler->SetOption("ResourceSpecFile", this->ResourceSpecFile.c_str()); + handler->SetOption("ResourceSpecFile", this->ResourceSpecFile); } if (!this->StopTime.empty()) { this->CTest->SetStopTime(this->StopTime); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 797cb01..6655bf7 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -79,7 +79,7 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->SetError("source directory not specified. Please use SOURCE tag"); return nullptr; } - handler->SetOption("SourceDirectory", source_dir.c_str()); + handler->SetOption("SourceDirectory", source_dir); handler->SetQuiet(this->Quiet); return handler; } |