diff options
author | Vitaly Stakhovsky <vvs31415@users.noreply.gitlab.com> | 2023-01-03 12:50:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@users.noreply.gitlab.com> | 2023-01-03 12:49:22 (GMT) |
commit | 0ee984defa7cd45d6596b9873886f20b72d02efd (patch) | |
tree | 327e3d31c1c7c6a9ef36d65960c2b5ab118f49aa | |
parent | 323ff3e9aba89b256906a6a14f336091e83a53fd (diff) | |
download | CMake-0ee984defa7cd45d6596b9873886f20b72d02efd.zip CMake-0ee984defa7cd45d6596b9873886f20b72d02efd.tar.gz CMake-0ee984defa7cd45d6596b9873886f20b72d02efd.tar.bz2 |
CTest: Use std::string arguments
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.cxx | 12 | ||||
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.h | 12 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 43 | ||||
-rw-r--r-- | Source/cmCTest.h | 2 |
4 files changed, 28 insertions, 41 deletions
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 1c292c7..728e88e 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -26,13 +26,8 @@ namespace { * is non-null, otherwise removing key `op` (if it exists). */ void SetMapValue(cmCTestGenericHandler::t_StringToString& map, - const std::string& op, const char* value) + const std::string& op, const std::string& value) { - if (!value) { - map.erase(op); - return; - } - map[op] = value; } void SetMapValue(cmCTestGenericHandler::t_StringToString& map, @@ -47,7 +42,8 @@ void SetMapValue(cmCTestGenericHandler::t_StringToString& map, } } -void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) +void cmCTestGenericHandler::SetOption(const std::string& op, + const std::string& value) { SetMapValue(this->Options, op, value); } @@ -57,7 +53,7 @@ void cmCTestGenericHandler::SetOption(const std::string& op, cmValue value) } void cmCTestGenericHandler::SetPersistentOption(const std::string& op, - const char* value) + const std::string& value) { this->SetOption(op, value); SetMapValue(this->PersistentOptions, op, value); diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 4bdb9c2..a0197d6 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -85,17 +85,9 @@ public: * so calling a single-getter for a key that has only been set * 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, cmValue(value)); - } + void SetPersistentOption(const std::string& op, const std::string& value); void SetPersistentOption(const std::string& op, cmValue value); - void SetOption(const std::string& op, const char* value); - void SetOption(const std::string& op, const std::string& value) - { - this->SetOption(op, cmValue(value)); - } + void SetOption(const std::string& op, const std::string& value); void SetOption(const std::string& op, cmValue value); cmValue GetOption(const std::string& op); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f60a1e9..2938294 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -410,7 +410,8 @@ cmCTest::Part cmCTest::GetPartFromName(const std::string& name) return PartCount; } -int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) +int cmCTest::Initialize(const std::string& binary_dir, + cmCTestStartCommand* command) { bool quiet = false; if (command && command->ShouldBeQuiet()) { @@ -683,7 +684,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) this->SetCTestConfigurationFromCMakeVariable( mf, "BuildName", "CTEST_BUILD_NAME", command->ShouldBeQuiet()); - if (!this->Initialize(bld_dir.c_str(), command)) { + if (!this->Initialize(bld_dir, command)) { return false; } cmCTestOptionalLog(this, OUTPUT, @@ -943,8 +944,7 @@ int cmCTest::ProcessSteps() (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { cmCTestUpdateHandler* uphandler = this->GetUpdateHandler(); uphandler->SetPersistentOption( - "SourceDirectory", - this->GetCTestConfiguration("SourceDirectory").c_str()); + "SourceDirectory", this->GetCTestConfiguration("SourceDirectory")); update_count = uphandler->ProcessHandler(); if (update_count < 0) { res |= cmCTest::UPDATE_ERRORS; @@ -2139,9 +2139,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption("TestsToRunInformation", - args[i].c_str()); + args[i]); this->GetMemCheckHandler()->SetPersistentOption("TestsToRunInformation", - args[i].c_str()); + args[i]); } else if (this->CheckArgument(arg, "-U"_s, "--union")) { this->GetTestHandler()->SetPersistentOption("UseUnion", "true"); this->GetMemCheckHandler()->SetPersistentOption("UseUnion", "true"); @@ -2149,9 +2149,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption("IncludeRegularExpression", - args[i].c_str()); + args[i]); this->GetMemCheckHandler()->SetPersistentOption("IncludeRegularExpression", - args[i].c_str()); + args[i]); } else if (this->CheckArgument(arg, "-L"_s, "--label-regex") && i < args.size() - 1) { i++; @@ -2172,41 +2172,40 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption("ExcludeRegularExpression", - args[i].c_str()); + args[i]); this->GetMemCheckHandler()->SetPersistentOption("ExcludeRegularExpression", - args[i].c_str()); + args[i]); } else if (this->CheckArgument(arg, "-FA"_s, "--fixture-exclude-any") && i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption( - "ExcludeFixtureRegularExpression", args[i].c_str()); + "ExcludeFixtureRegularExpression", args[i]); this->GetMemCheckHandler()->SetPersistentOption( - "ExcludeFixtureRegularExpression", args[i].c_str()); + "ExcludeFixtureRegularExpression", args[i]); } else if (this->CheckArgument(arg, "-FS"_s, "--fixture-exclude-setup") && i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption( - "ExcludeFixtureSetupRegularExpression", args[i].c_str()); + "ExcludeFixtureSetupRegularExpression", args[i]); this->GetMemCheckHandler()->SetPersistentOption( - "ExcludeFixtureSetupRegularExpression", args[i].c_str()); + "ExcludeFixtureSetupRegularExpression", args[i]); } else if (this->CheckArgument(arg, "-FC"_s, "--fixture-exclude-cleanup") && i < args.size() - 1) { i++; this->GetTestHandler()->SetPersistentOption( - "ExcludeFixtureCleanupRegularExpression", args[i].c_str()); + "ExcludeFixtureCleanupRegularExpression", args[i]); this->GetMemCheckHandler()->SetPersistentOption( - "ExcludeFixtureCleanupRegularExpression", args[i].c_str()); + "ExcludeFixtureCleanupRegularExpression", args[i]); } else if (this->CheckArgument(arg, "--resource-spec-file"_s) && i < args.size() - 1) { i++; - this->GetTestHandler()->SetPersistentOption("ResourceSpecFile", - args[i].c_str()); + this->GetTestHandler()->SetPersistentOption("ResourceSpecFile", args[i]); this->GetMemCheckHandler()->SetPersistentOption("ResourceSpecFile", - args[i].c_str()); + args[i]); } else if (this->CheckArgument(arg, "--rerun-failed"_s)) { @@ -2314,8 +2313,8 @@ void cmCTest::SetPersistentOptionIfNotEmpty(const std::string& value, const std::string& optionName) { if (!value.empty()) { - this->GetTestHandler()->SetPersistentOption(optionName, value.c_str()); - this->GetMemCheckHandler()->SetPersistentOption(optionName, value.c_str()); + this->GetTestHandler()->SetPersistentOption(optionName, value); + this->GetMemCheckHandler()->SetPersistentOption(optionName, value); } } @@ -2903,7 +2902,7 @@ int cmCTest::ExecuteTests() } } - if (!this->Initialize(workDir.c_str(), nullptr)) { + if (!this->Initialize(workDir, nullptr)) { res = 12; cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard." << std::endl); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 0017b3e..9a8d5a6 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -481,7 +481,7 @@ private: * call this method because it sets CTEST_COMMAND to drive a build * through the ctest command line. */ - int Initialize(const char* binary_dir, cmCTestStartCommand* command); + int Initialize(const std::string& binary_dir, cmCTestStartCommand* command); /** parse the option after -D and convert it into the appropriate steps */ bool AddTestsForDashboardType(std::string& targ); |