cmCTest*Command: Access Makefile through an alias

At the top of each function that requires access to Makefile,
declare an alias `mf = this->Makefile`.  Then replace all occurrences
of `this->Makefile->` with `mf.`.  The intention is to make following
changes easier to review.
This commit is contained in:
Daniel Pfeifer
2024-10-30 20:47:08 +01:00
parent caa449493b
commit 26a697f7c1
9 changed files with 108 additions and 116 deletions
+16 -18
View File
@@ -51,17 +51,16 @@ bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler( std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
HandlerArguments& arguments) HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<BuildArguments&>(arguments); auto const& args = static_cast<BuildArguments&>(arguments);
auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest); auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest);
cmValue ctestBuildCommand = cmValue ctestBuildCommand = mf.GetDefinition("CTEST_BUILD_COMMAND");
this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
if (cmNonempty(ctestBuildCommand)) { if (cmNonempty(ctestBuildCommand)) {
this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand, this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand,
args.Quiet); args.Quiet);
} else { } else {
cmValue cmakeGeneratorName = cmValue cmakeGeneratorName = mf.GetDefinition("CTEST_CMAKE_GENERATOR");
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
// Build configuration is determined by: CONFIGURATION argument, // Build configuration is determined by: CONFIGURATION argument,
// or CTEST_BUILD_CONFIGURATION script variable, or // or CTEST_BUILD_CONFIGURATION script variable, or
@@ -69,7 +68,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
// line argument... in that order. // line argument... in that order.
// //
cmValue ctestBuildConfiguration = cmValue ctestBuildConfiguration =
this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); mf.GetDefinition("CTEST_BUILD_CONFIGURATION");
std::string cmakeBuildConfiguration = cmNonempty(args.Configuration) std::string cmakeBuildConfiguration = cmNonempty(args.Configuration)
? args.Configuration ? args.Configuration
: cmNonempty(ctestBuildConfiguration) ? *ctestBuildConfiguration : cmNonempty(ctestBuildConfiguration) ? *ctestBuildConfiguration
@@ -77,10 +76,10 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
const std::string& cmakeBuildAdditionalFlags = cmNonempty(args.Flags) const std::string& cmakeBuildAdditionalFlags = cmNonempty(args.Flags)
? args.Flags ? args.Flags
: this->Makefile->GetSafeDefinition("CTEST_BUILD_FLAGS"); : mf.GetSafeDefinition("CTEST_BUILD_FLAGS");
const std::string& cmakeBuildTarget = cmNonempty(args.Target) const std::string& cmakeBuildTarget = cmNonempty(args.Target)
? args.Target ? args.Target
: this->Makefile->GetSafeDefinition("CTEST_BUILD_TARGET"); : mf.GetSafeDefinition("CTEST_BUILD_TARGET");
if (cmNonempty(cmakeGeneratorName)) { if (cmNonempty(cmakeGeneratorName)) {
if (cmakeBuildConfiguration.empty()) { if (cmakeBuildConfiguration.empty()) {
@@ -88,12 +87,11 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
} }
auto globalGenerator = auto globalGenerator =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( mf.GetCMakeInstance()->CreateGlobalGenerator(*cmakeGeneratorName);
*cmakeGeneratorName);
if (!globalGenerator) { if (!globalGenerator) {
std::string e = cmStrCat("could not create generator named \"", std::string e = cmStrCat("could not create generator named \"",
*cmakeGeneratorName, '"'); *cmakeGeneratorName, '"');
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); mf.IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccurred(); cmSystemTools::SetFatalErrorOccurred();
return nullptr; return nullptr;
} }
@@ -104,7 +102,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand( std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
cmakeBuildTarget, cmakeBuildConfiguration, args.ParallelLevel, cmakeBuildTarget, cmakeBuildConfiguration, args.ParallelLevel,
cmakeBuildAdditionalFlags, this->Makefile->IgnoreErrorsCMP0061()); cmakeBuildAdditionalFlags, mf.IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" << buildCommand << "\n", "SetMakeCommand:" << buildCommand << "\n",
args.Quiet); args.Quiet);
@@ -123,14 +121,13 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
} }
} }
if (cmValue useLaunchers = if (cmValue useLaunchers = mf.GetDefinition("CTEST_USE_LAUNCHERS")) {
this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers, this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers,
args.Quiet); args.Quiet);
} }
if (cmValue labelsForSubprojects = if (cmValue labelsForSubprojects =
this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { mf.GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
this->CTest->SetCTestConfiguration("LabelsForSubprojects", this->CTest->SetCTestConfiguration("LabelsForSubprojects",
*labelsForSubprojects, args.Quiet); *labelsForSubprojects, args.Quiet);
} }
@@ -142,14 +139,15 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
void cmCTestBuildCommand::ProcessAdditionalValues( void cmCTestBuildCommand::ProcessAdditionalValues(
cmCTestGenericHandler* generic, HandlerArguments const& arguments) cmCTestGenericHandler* generic, HandlerArguments const& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<BuildArguments const&>(arguments); auto const& args = static_cast<BuildArguments const&>(arguments);
auto const* handler = static_cast<cmCTestBuildHandler*>(generic); auto const* handler = static_cast<cmCTestBuildHandler*>(generic);
if (!args.NumberErrors.empty()) { if (!args.NumberErrors.empty()) {
this->Makefile->AddDefinition(args.NumberErrors, mf.AddDefinition(args.NumberErrors,
std::to_string(handler->GetTotalErrors())); std::to_string(handler->GetTotalErrors()));
} }
if (!args.NumberWarnings.empty()) { if (!args.NumberWarnings.empty()) {
this->Makefile->AddDefinition(args.NumberWarnings, mf.AddDefinition(args.NumberWarnings,
std::to_string(handler->GetTotalWarnings())); std::to_string(handler->GetTotalWarnings()));
} }
} }
+9 -10
View File
@@ -33,6 +33,7 @@ std::unique_ptr<cmCommand> cmCTestConfigureCommand::Clone()
std::unique_ptr<cmCTestGenericHandler> std::unique_ptr<cmCTestGenericHandler>
cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments) cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<ConfigureArguments&>(arguments); auto const& args = static_cast<ConfigureArguments&>(arguments);
cmList options; cmList options;
@@ -48,15 +49,13 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
return nullptr; return nullptr;
} }
cmValue ctestConfigureCommand = cmValue ctestConfigureCommand = mf.GetDefinition("CTEST_CONFIGURE_COMMAND");
this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
if (cmNonempty(ctestConfigureCommand)) { if (cmNonempty(ctestConfigureCommand)) {
this->CTest->SetCTestConfiguration("ConfigureCommand", this->CTest->SetCTestConfiguration("ConfigureCommand",
*ctestConfigureCommand, args.Quiet); *ctestConfigureCommand, args.Quiet);
} else { } else {
cmValue cmakeGeneratorName = cmValue cmakeGeneratorName = mf.GetDefinition("CTEST_CMAKE_GENERATOR");
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
if (cmNonempty(cmakeGeneratorName)) { if (cmNonempty(cmakeGeneratorName)) {
const std::string& source_dir = const std::string& source_dir =
this->CTest->GetCTestConfiguration("SourceDirectory"); this->CTest->GetCTestConfiguration("SourceDirectory");
@@ -79,8 +78,8 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
bool multiConfig = false; bool multiConfig = false;
bool cmakeBuildTypeInOptions = false; bool cmakeBuildTypeInOptions = false;
auto gg = this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( auto gg =
*cmakeGeneratorName); mf.GetCMakeInstance()->CreateGlobalGenerator(*cmakeGeneratorName);
if (gg) { if (gg) {
multiConfig = gg->IsMultiConfig(); multiConfig = gg->IsMultiConfig();
gg.reset(); gg.reset();
@@ -107,7 +106,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
} }
if (this->Makefile->IsOn("CTEST_USE_LAUNCHERS")) { if (mf.IsOn("CTEST_USE_LAUNCHERS")) {
cmakeConfigureCommand += " \"-DCTEST_USE_LAUNCHERS:BOOL=TRUE\""; cmakeConfigureCommand += " \"-DCTEST_USE_LAUNCHERS:BOOL=TRUE\"";
} }
@@ -116,7 +115,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
cmValue cmakeGeneratorPlatform = cmValue cmakeGeneratorPlatform =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); mf.GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
if (cmNonempty(cmakeGeneratorPlatform)) { if (cmNonempty(cmakeGeneratorPlatform)) {
cmakeConfigureCommand += " \"-A"; cmakeConfigureCommand += " \"-A";
cmakeConfigureCommand += *cmakeGeneratorPlatform; cmakeConfigureCommand += *cmakeGeneratorPlatform;
@@ -124,7 +123,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
} }
cmValue cmakeGeneratorToolset = cmValue cmakeGeneratorToolset =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); mf.GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
if (cmNonempty(cmakeGeneratorToolset)) { if (cmNonempty(cmakeGeneratorToolset)) {
cmakeConfigureCommand += " \"-T"; cmakeConfigureCommand += " \"-T";
cmakeConfigureCommand += *cmakeGeneratorToolset; cmakeConfigureCommand += *cmakeGeneratorToolset;
@@ -152,7 +151,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
} }
if (cmValue labelsForSubprojects = if (cmValue labelsForSubprojects =
this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { mf.GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
this->CTest->SetCTestConfiguration("LabelsForSubprojects", this->CTest->SetCTestConfiguration("LabelsForSubprojects",
*labelsForSubprojects, args.Quiet); *labelsForSubprojects, args.Quiet);
} }
+5 -3
View File
@@ -14,6 +14,8 @@
#include "cmCTestGenericHandler.h" #include "cmCTestGenericHandler.h"
#include "cmCommand.h" #include "cmCommand.h"
class cmMakefile;
std::unique_ptr<cmCommand> cmCTestCoverageCommand::Clone() std::unique_ptr<cmCommand> cmCTestCoverageCommand::Clone()
{ {
auto ni = cm::make_unique<cmCTestCoverageCommand>(); auto ni = cm::make_unique<cmCTestCoverageCommand>();
@@ -24,12 +26,12 @@ std::unique_ptr<cmCommand> cmCTestCoverageCommand::Clone()
std::unique_ptr<cmCTestGenericHandler> std::unique_ptr<cmCTestGenericHandler>
cmCTestCoverageCommand::InitializeHandler(HandlerArguments& arguments) cmCTestCoverageCommand::InitializeHandler(HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto& args = static_cast<CoverageArguments&>(arguments); auto& args = static_cast<CoverageArguments&>(arguments);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", args.Quiet); &mf, "CoverageCommand", "CTEST_COVERAGE_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", &mf, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", args.Quiet);
args.Quiet);
auto handler = cm::make_unique<cmCTestCoverageHandler>(this->CTest); auto handler = cm::make_unique<cmCTestCoverageHandler>(this->CTest);
// If a LABELS option was given, select only files with the labels. // If a LABELS option was given, select only files with the labels.
+12 -12
View File
@@ -116,9 +116,11 @@ bool cmCTestHandlerCommand::InvokeImpl(
return true; return true;
} }
bool cmCTestHandlerCommand::ExecuteHandlerCommand( bool cmCTestHandlerCommand::ExecuteHandlerCommand(HandlerArguments& args,
HandlerArguments& args, cmExecutionStatus& /*status*/) cmExecutionStatus& status)
{ {
cmMakefile& mf = status.GetMakefile();
// Process input arguments. // Process input arguments.
this->CheckArguments(args); this->CheckArguments(args);
@@ -126,8 +128,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(
// CTEST_CONFIGURATION_TYPE script variable if it is defined. // CTEST_CONFIGURATION_TYPE script variable if it is defined.
// The current script value trumps the -C argument on the command // The current script value trumps the -C argument on the command
// line. // line.
cmValue ctestConfigType = cmValue ctestConfigType = mf.GetDefinition("CTEST_CONFIGURATION_TYPE");
this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE");
if (ctestConfigType) { if (ctestConfigType) {
this->CTest->SetConfigType(*ctestConfigType); this->CTest->SetConfigType(*ctestConfigType);
} }
@@ -137,8 +138,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(
"BuildDirectory", cmSystemTools::CollapseFullPath(args.Build), "BuildDirectory", cmSystemTools::CollapseFullPath(args.Build),
args.Quiet); args.Quiet);
} else { } else {
std::string const& bdir = std::string const& bdir = mf.GetSafeDefinition("CTEST_BINARY_DIRECTORY");
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
if (!bdir.empty()) { if (!bdir.empty()) {
this->CTest->SetCTestConfiguration( this->CTest->SetCTestConfiguration(
"BuildDirectory", cmSystemTools::CollapseFullPath(bdir), args.Quiet); "BuildDirectory", cmSystemTools::CollapseFullPath(bdir), args.Quiet);
@@ -157,11 +157,11 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(
this->CTest->SetCTestConfiguration( this->CTest->SetCTestConfiguration(
"SourceDirectory", "SourceDirectory",
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(
this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")), mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY")),
args.Quiet); args.Quiet);
} }
if (cmValue changeId = this->Makefile->GetDefinition("CTEST_CHANGE_ID")) { if (cmValue changeId = mf.GetDefinition("CTEST_CHANGE_ID")) {
this->CTest->SetCTestConfiguration("ChangeId", *changeId, args.Quiet); this->CTest->SetCTestConfiguration("ChangeId", *changeId, args.Quiet);
} }
@@ -176,7 +176,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(
handler->SetAppendXML(args.Append); handler->SetAppendXML(args.Append);
handler->PopulateCustomVectors(this->Makefile); handler->PopulateCustomVectors(&mf);
if (!args.SubmitIndex.empty()) { if (!args.SubmitIndex.empty()) {
handler->SetSubmitIndex(atoi(args.SubmitIndex.c_str())); handler->SetSubmitIndex(atoi(args.SubmitIndex.c_str()));
} }
@@ -188,12 +188,12 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(
} }
// reread time limit, as the variable may have been modified. // reread time limit, as the variable may have been modified.
this->CTest->SetTimeLimit(this->Makefile->GetDefinition("CTEST_TIME_LIMIT")); this->CTest->SetTimeLimit(mf.GetDefinition("CTEST_TIME_LIMIT"));
handler->SetCMakeInstance(this->Makefile->GetCMakeInstance()); handler->SetCMakeInstance(mf.GetCMakeInstance());
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();
if (!args.ReturnValue.empty()) { if (!args.ReturnValue.empty()) {
this->Makefile->AddDefinition(args.ReturnValue, std::to_string(res)); mf.AddDefinition(args.ReturnValue, std::to_string(res));
} }
this->ProcessAdditionalValues(handler.get(), args); this->ProcessAdditionalValues(handler.get(), args);
return true; return true;
+11 -10
View File
@@ -24,22 +24,22 @@ std::unique_ptr<cmCommand> cmCTestMemCheckCommand::Clone()
std::unique_ptr<cmCTestTestHandler> std::unique_ptr<cmCTestTestHandler>
cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args) cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args)
{ {
cmMakefile& mf = *this->Makefile;
auto handler = cm::make_unique<cmCTestMemCheckHandler>(this->CTest); auto handler = cm::make_unique<cmCTestMemCheckHandler>(this->CTest);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", args.Quiet); &mf, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckSanitizerOptions", &mf, "MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS",
"CTEST_MEMORYCHECK_SANITIZER_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND",
args.Quiet); args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckCommandOptions", &mf, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND", args.Quiet);
"CTEST_MEMORYCHECK_COMMAND_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckSuppressionFile", &mf, "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS",
"CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", args.Quiet); args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
&mf, "MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE",
args.Quiet);
handler->SetQuiet(args.Quiet); handler->SetQuiet(args.Quiet);
return std::unique_ptr<cmCTestTestHandler>(std::move(handler)); return std::unique_ptr<cmCTestTestHandler>(std::move(handler));
@@ -48,9 +48,10 @@ cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args)
void cmCTestMemCheckCommand::ProcessAdditionalValues( void cmCTestMemCheckCommand::ProcessAdditionalValues(
cmCTestGenericHandler* handler, HandlerArguments const& arguments) cmCTestGenericHandler* handler, HandlerArguments const& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<MemCheckArguments const&>(arguments); auto const& args = static_cast<MemCheckArguments const&>(arguments);
if (!args.DefectCount.empty()) { if (!args.DefectCount.empty()) {
this->Makefile->AddDefinition( mf.AddDefinition(
args.DefectCount, args.DefectCount,
std::to_string( std::to_string(
static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount())); static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount()));
+24 -27
View File
@@ -34,31 +34,30 @@ std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler( std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler(
HandlerArguments& arguments) HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<SubmitArguments&>(arguments); auto const& args = static_cast<SubmitArguments&>(arguments);
cmValue submitURL = !args.SubmitURL.empty() cmValue submitURL = !args.SubmitURL.empty()
? cmValue(args.SubmitURL) ? cmValue(args.SubmitURL)
: this->Makefile->GetDefinition("CTEST_SUBMIT_URL"); : mf.GetDefinition("CTEST_SUBMIT_URL");
if (submitURL) { if (submitURL) {
this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, args.Quiet); this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, args.Quiet);
} else { } else {
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "DropMethod", "CTEST_DROP_METHOD", args.Quiet); &mf, "DropMethod", "CTEST_DROP_METHOD", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", args.Quiet); &mf, "DropSiteUser", "CTEST_DROP_SITE_USER", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", &mf, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "DropSite", "CTEST_DROP_SITE", args.Quiet); &mf, "DropSite", "CTEST_DROP_SITE", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "DropLocation", "CTEST_DROP_LOCATION", args.Quiet); &mf, "DropLocation", "CTEST_DROP_LOCATION", args.Quiet);
} }
if (!this->CTest->SetCTestConfigurationFromCMakeVariable( if (!this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "TLSVersion", "CTEST_TLS_VERSION", args.Quiet)) { &mf, "TLSVersion", "CTEST_TLS_VERSION", args.Quiet)) {
if (cmValue tlsVersionVar = if (cmValue tlsVersionVar = mf.GetDefinition("CMAKE_TLS_VERSION")) {
this->Makefile->GetDefinition("CMAKE_TLS_VERSION")) {
cmCTestOptionalLog( cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT, this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetCTestConfiguration from CMAKE_TLS_VERSION:TLSVersion:" "SetCTestConfiguration from CMAKE_TLS_VERSION:TLSVersion:"
@@ -78,9 +77,8 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler(
} }
} }
if (!this->CTest->SetCTestConfigurationFromCMakeVariable( if (!this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "TLSVerify", "CTEST_TLS_VERIFY", args.Quiet)) { &mf, "TLSVerify", "CTEST_TLS_VERIFY", args.Quiet)) {
if (cmValue tlsVerifyVar = if (cmValue tlsVerifyVar = mf.GetDefinition("CMAKE_TLS_VERIFY")) {
this->Makefile->GetDefinition("CMAKE_TLS_VERIFY")) {
cmCTestOptionalLog( cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT, this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetCTestConfiguration from CMAKE_TLS_VERIFY:TLSVerify:" "SetCTestConfiguration from CMAKE_TLS_VERIFY:TLSVerify:"
@@ -100,21 +98,18 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler(
} }
} }
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", args.Quiet); &mf, "CurlOptions", "CTEST_CURL_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "SubmitInactivityTimeout", &mf, "SubmitInactivityTimeout", "CTEST_SUBMIT_INACTIVITY_TIMEOUT",
"CTEST_SUBMIT_INACTIVITY_TIMEOUT", args.Quiet); args.Quiet);
cmValue notesFilesVariable = cmValue notesFilesVariable = mf.GetDefinition("CTEST_NOTES_FILES");
this->Makefile->GetDefinition("CTEST_NOTES_FILES");
if (notesFilesVariable) { if (notesFilesVariable) {
cmList notesFiles{ *notesFilesVariable }; cmList notesFiles{ *notesFilesVariable };
this->CTest->GenerateNotesFile(this->Makefile->GetCMakeInstance(), this->CTest->GenerateNotesFile(mf.GetCMakeInstance(), notesFiles);
notesFiles);
} }
cmValue extraFilesVariable = cmValue extraFilesVariable = mf.GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
if (extraFilesVariable) { if (extraFilesVariable) {
cmList extraFiles{ *extraFilesVariable }; cmList extraFiles{ *extraFilesVariable };
if (!this->CTest->SubmitExtraFiles(extraFiles)) { if (!this->CTest->SubmitExtraFiles(extraFiles)) {
@@ -215,14 +210,15 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments) void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto& args = static_cast<SubmitArguments&>(arguments); auto& args = static_cast<SubmitArguments&>(arguments);
if (args.Parts) { if (args.Parts) {
cm::erase_if(*(args.Parts), [this](std::string const& arg) -> bool { cm::erase_if(*(args.Parts), [this, &mf](std::string const& arg) -> bool {
cmCTest::Part p = this->CTest->GetPartFromName(arg); cmCTest::Part p = this->CTest->GetPartFromName(arg);
if (p == cmCTest::PartCount) { if (p == cmCTest::PartCount) {
std::ostringstream e; std::ostringstream e;
e << "Part name \"" << arg << "\" is invalid."; e << "Part name \"" << arg << "\" is invalid.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
return true; return true;
} }
return false; return false;
@@ -230,12 +226,12 @@ void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments)
} }
if (args.Files) { if (args.Files) {
cm::erase_if(*(args.Files), [this](std::string const& arg) -> bool { cm::erase_if(*(args.Files), [&mf](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) { if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e; std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit " e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file."; << "a non-existent file.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
return true; return true;
} }
return false; return false;
@@ -246,8 +242,9 @@ void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments)
void cmCTestSubmitCommand::ProcessAdditionalValues( void cmCTestSubmitCommand::ProcessAdditionalValues(
cmCTestGenericHandler*, HandlerArguments const& arguments) cmCTestGenericHandler*, HandlerArguments const& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto const& args = static_cast<SubmitArguments const&>(arguments); auto const& args = static_cast<SubmitArguments const&>(arguments);
if (!args.BuildID.empty()) { if (!args.BuildID.empty()) {
this->Makefile->AddDefinition(args.BuildID, this->CTest->GetBuildID()); mf.AddDefinition(args.BuildID, this->CTest->GetBuildID());
} }
} }
+5 -5
View File
@@ -32,8 +32,9 @@ std::unique_ptr<cmCommand> cmCTestTestCommand::Clone()
std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler( std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
HandlerArguments& arguments) HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto& args = static_cast<TestArguments&>(arguments); auto& args = static_cast<TestArguments&>(arguments);
cmValue ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); cmValue ctestTimeout = mf.GetDefinition("CTEST_TEST_TIMEOUT");
cmDuration timeout; cmDuration timeout;
if (ctestTimeout) { if (ctestTimeout) {
@@ -47,8 +48,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
} }
this->CTest->SetTimeOut(timeout); this->CTest->SetTimeOut(timeout);
cmValue resourceSpecFile = cmValue resourceSpecFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE");
this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE");
if (args.ResourceSpecFile.empty() && resourceSpecFile) { if (args.ResourceSpecFile.empty() && resourceSpecFile) {
args.ResourceSpecFile = *resourceSpecFile; args.ResourceSpecFile = *resourceSpecFile;
} }
@@ -113,7 +113,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
// or CTEST_TEST_LOAD script variable, or ctest --test-load // or CTEST_TEST_LOAD script variable, or ctest --test-load
// command line argument... in that order. // command line argument... in that order.
unsigned long testLoad; unsigned long testLoad;
cmValue ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); cmValue ctestTestLoad = mf.GetDefinition("CTEST_TEST_LOAD");
if (!args.TestLoad.empty()) { if (!args.TestLoad.empty()) {
if (!cmStrToULong(args.TestLoad, &testLoad)) { if (!cmStrToULong(args.TestLoad, &testLoad)) {
testLoad = 0; testLoad = 0;
@@ -134,7 +134,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
handler->SetTestLoad(testLoad); handler->SetTestLoad(testLoad);
if (cmValue labelsForSubprojects = if (cmValue labelsForSubprojects =
this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { mf.GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
this->CTest->SetCTestConfiguration("LabelsForSubprojects", this->CTest->SetCTestConfiguration("LabelsForSubprojects",
*labelsForSubprojects, args.Quiet); *labelsForSubprojects, args.Quiet);
} }
+23 -29
View File
@@ -23,6 +23,7 @@ std::unique_ptr<cmCommand> cmCTestUpdateCommand::Clone()
std::unique_ptr<cmCTestGenericHandler> cmCTestUpdateCommand::InitializeHandler( std::unique_ptr<cmCTestGenericHandler> cmCTestUpdateCommand::InitializeHandler(
HandlerArguments& args) HandlerArguments& args)
{ {
cmMakefile& mf = *this->Makefile;
if (!args.Source.empty()) { if (!args.Source.empty()) {
this->CTest->SetCTestConfiguration( this->CTest->SetCTestConfiguration(
"SourceDirectory", cmSystemTools::CollapseFullPath(args.Source), "SourceDirectory", cmSystemTools::CollapseFullPath(args.Source),
@@ -31,61 +32,54 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestUpdateCommand::InitializeHandler(
this->CTest->SetCTestConfiguration( this->CTest->SetCTestConfiguration(
"SourceDirectory", "SourceDirectory",
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(
this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")), mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY")),
args.Quiet); args.Quiet);
} }
std::string source_dir = std::string source_dir =
this->CTest->GetCTestConfiguration("SourceDirectory"); this->CTest->GetCTestConfiguration("SourceDirectory");
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", args.Quiet); &mf, "UpdateCommand", "CTEST_UPDATE_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", args.Quiet); &mf, "UpdateOptions", "CTEST_UPDATE_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", args.Quiet); &mf, "CVSCommand", "CTEST_CVS_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS", &mf, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", args.Quiet); &mf, "SVNCommand", "CTEST_SVN_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS", &mf, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", args.Quiet); &mf, "SVNOptions", "CTEST_SVN_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", args.Quiet); &mf, "BZRCommand", "CTEST_BZR_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS", &mf, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", args.Quiet); &mf, "GITCommand", "CTEST_GIT_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", &mf, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", &mf, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", args.Quiet); &mf, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY", &mf, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "UpdateVersionOverride", "CTEST_UPDATE_VERSION_OVERRIDE", &mf, "UpdateVersionOverride", "CTEST_UPDATE_VERSION_OVERRIDE", args.Quiet);
args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "HGCommand", "CTEST_HG_COMMAND", args.Quiet); &mf, "HGCommand", "CTEST_HG_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", args.Quiet); &mf, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4Command", "CTEST_P4_COMMAND", args.Quiet); &mf, "P4Command", "CTEST_P4_COMMAND", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", args.Quiet); &mf, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4Client", "CTEST_P4_CLIENT", args.Quiet); &mf, "P4Client", "CTEST_P4_CLIENT", args.Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4Options", "CTEST_P4_OPTIONS", args.Quiet); &mf, "P4Options", "CTEST_P4_OPTIONS", args.Quiet);
auto handler = cm::make_unique<cmCTestUpdateHandler>(this->CTest); auto handler = cm::make_unique<cmCTestUpdateHandler>(this->CTest);
if (source_dir.empty()) { if (source_dir.empty()) {
+3 -2
View File
@@ -29,13 +29,14 @@ std::unique_ptr<cmCommand> cmCTestUploadCommand::Clone()
void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments) void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments)
{ {
cmMakefile& mf = *this->Makefile;
auto& args = static_cast<UploadArguments&>(arguments); auto& args = static_cast<UploadArguments&>(arguments);
cm::erase_if(args.Files, [this](std::string const& arg) -> bool { cm::erase_if(args.Files, [&mf](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) { if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e; std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit " e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file."; << "a non-existent file.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
return true; return true;
} }
return false; return false;