Explorar el Código

cmCTest*Command: Direct use of cmExecutionStatus

Make sure that getting Makefile and setting Error is both done
through a `status` argument rather than through `cmCommand`.
Daniel Pfeifer hace 1 año
padre
commit
0e995d4897

+ 7 - 7
Source/CTest/cmCTestBuildCommand.cxx

@@ -13,6 +13,7 @@
 #include "cmCTestBuildHandler.h"
 #include "cmCTestGenericHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
@@ -21,8 +22,6 @@
 #include "cmValue.h"
 #include "cmake.h"
 
-class cmExecutionStatus;
-
 std::unique_ptr<cmCommand> cmCTestBuildCommand::Clone()
 {
   auto ni = cm::make_unique<cmCTestBuildCommand>();
@@ -49,9 +48,9 @@ bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
 }
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
-  HandlerArguments& arguments)
+  HandlerArguments& arguments, cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<BuildArguments&>(arguments);
   auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest);
 
@@ -116,7 +115,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
         "is set. Otherwise, set CTEST_BUILD_COMMAND to build the project "
         "with a custom command line.";
       /* clang-format on */
-      this->SetError(ostr.str());
+      status.SetError(ostr.str());
       return nullptr;
     }
   }
@@ -137,9 +136,10 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler(
 }
 
 void cmCTestBuildCommand::ProcessAdditionalValues(
-  cmCTestGenericHandler* generic, HandlerArguments const& arguments)
+  cmCTestGenericHandler* generic, HandlerArguments const& arguments,
+  cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<BuildArguments const&>(arguments);
   auto const* handler = static_cast<cmCTestBuildHandler*>(generic);
   if (!args.NumberErrors.empty()) {

+ 3 - 2
Source/CTest/cmCTestBuildCommand.h

@@ -37,10 +37,11 @@ private:
   std::string GetName() const override { return "ctest_build"; }
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   void ProcessAdditionalValues(cmCTestGenericHandler* handler,
-                               HandlerArguments const& arguments) override;
+                               HandlerArguments const& arguments,
+                               cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 8 - 6
Source/CTest/cmCTestConfigureCommand.cxx

@@ -15,6 +15,7 @@
 #include "cmCTestConfigureHandler.h"
 #include "cmCTestGenericHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmGlobalGenerator.h"
 #include "cmList.h"
 #include "cmMakefile.h"
@@ -31,9 +32,10 @@ std::unique_ptr<cmCommand> cmCTestConfigureCommand::Clone()
 }
 
 std::unique_ptr<cmCTestGenericHandler>
-cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
+cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments,
+                                           cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<ConfigureArguments&>(arguments);
   cmList options;
 
@@ -42,7 +44,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
   }
 
   if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
-    this->SetError(
+    status.SetError(
       "Build directory not specified. Either use BUILD "
       "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
       "variable");
@@ -60,7 +62,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
       const std::string& source_dir =
         this->CTest->GetCTestConfiguration("SourceDirectory");
       if (source_dir.empty()) {
-        this->SetError(
+        status.SetError(
           "Source directory not specified. Either use SOURCE "
           "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
           "variable");
@@ -71,7 +73,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
       if (!cmSystemTools::FileExists(cmakelists_file)) {
         std::ostringstream e;
         e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
-        this->SetError(e.str());
+        status.SetError(e.str());
         return nullptr;
       }
 
@@ -142,7 +144,7 @@ cmCTestConfigureCommand::InitializeHandler(HandlerArguments& arguments)
       this->CTest->SetCTestConfiguration("ConfigureCommand",
                                          cmakeConfigureCommand, args.Quiet);
     } else {
-      this->SetError(
+      status.SetError(
         "Configure command is not specified. If this is a "
         "\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, "
         "set CTEST_CONFIGURE_COMMAND.");

+ 1 - 1
Source/CTest/cmCTestConfigureCommand.h

@@ -31,7 +31,7 @@ private:
   std::string GetName() const override { return "ctest_configure"; }
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 4 - 2
Source/CTest/cmCTestCoverageCommand.cxx

@@ -13,6 +13,7 @@
 #include "cmCTestCoverageHandler.h"
 #include "cmCTestGenericHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 
 class cmMakefile;
 
@@ -24,9 +25,10 @@ std::unique_ptr<cmCommand> cmCTestCoverageCommand::Clone()
 }
 
 std::unique_ptr<cmCTestGenericHandler>
-cmCTestCoverageCommand::InitializeHandler(HandlerArguments& arguments)
+cmCTestCoverageCommand::InitializeHandler(HandlerArguments& arguments,
+                                          cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto& args = static_cast<CoverageArguments&>(arguments);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
     &mf, "CoverageCommand", "CTEST_COVERAGE_COMMAND", args.Quiet);

+ 1 - 1
Source/CTest/cmCTestCoverageCommand.h

@@ -34,7 +34,7 @@ private:
   std::string GetName() const override { return "ctest_coverage"; }
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 9 - 7
Source/CTest/cmCTestHandlerCommand.cxx

@@ -122,7 +122,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(HandlerArguments& args,
   cmMakefile& mf = status.GetMakefile();
 
   // Process input arguments.
-  this->CheckArguments(args);
+  this->CheckArguments(args, status);
 
   // Set the config type of this ctest to the current value of the
   // CTEST_CONFIGURATION_TYPE script variable if it is defined.
@@ -166,7 +166,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(HandlerArguments& args,
   }
 
   cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl);
-  auto handler = this->InitializeHandler(args);
+  auto handler = this->InitializeHandler(args, status);
   if (!handler) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot instantiate test handler " << this->GetName()
@@ -183,7 +183,7 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(HandlerArguments& args,
   cmWorkingDirectory workdir(
     this->CTest->GetCTestConfiguration("BuildDirectory"));
   if (workdir.Failed()) {
-    this->SetError(workdir.GetError());
+    status.SetError(workdir.GetError());
     return false;
   }
 
@@ -195,21 +195,23 @@ bool cmCTestHandlerCommand::ExecuteHandlerCommand(HandlerArguments& args,
   if (!args.ReturnValue.empty()) {
     mf.AddDefinition(args.ReturnValue, std::to_string(res));
   }
-  this->ProcessAdditionalValues(handler.get(), args);
+  this->ProcessAdditionalValues(handler.get(), args, status);
   return true;
 }
 
-void cmCTestHandlerCommand::CheckArguments(HandlerArguments&)
+void cmCTestHandlerCommand::CheckArguments(HandlerArguments&,
+                                           cmExecutionStatus&)
 {
 }
 
 std::unique_ptr<cmCTestGenericHandler>
-cmCTestHandlerCommand::InitializeHandler(HandlerArguments&)
+cmCTestHandlerCommand::InitializeHandler(HandlerArguments&, cmExecutionStatus&)
 {
   return nullptr;
 };
 
 void cmCTestHandlerCommand::ProcessAdditionalValues(cmCTestGenericHandler*,
-                                                    HandlerArguments const&)
+                                                    HandlerArguments const&,
+                                                    cmExecutionStatus&)
 {
 }

+ 5 - 3
Source/CTest/cmCTestHandlerCommand.h

@@ -85,11 +85,13 @@ private:
 
   virtual std::string GetName() const = 0;
 
-  virtual void CheckArguments(HandlerArguments& arguments);
+  virtual void CheckArguments(HandlerArguments& arguments,
+                              cmExecutionStatus& status);
 
   virtual std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments);
+    HandlerArguments& arguments, cmExecutionStatus& status);
 
   virtual void ProcessAdditionalValues(cmCTestGenericHandler*,
-                                       HandlerArguments const& arguments);
+                                       HandlerArguments const& arguments,
+                                       cmExecutionStatus& status);
 };

+ 7 - 4
Source/CTest/cmCTestMemCheckCommand.cxx

@@ -12,6 +12,7 @@
 #include "cmCTestMemCheckHandler.h"
 #include "cmCTestTestHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
 std::unique_ptr<cmCommand> cmCTestMemCheckCommand::Clone()
@@ -22,9 +23,10 @@ std::unique_ptr<cmCommand> cmCTestMemCheckCommand::Clone()
 }
 
 std::unique_ptr<cmCTestTestHandler>
-cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args)
+cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args,
+                                                cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto handler = cm::make_unique<cmCTestMemCheckHandler>(this->CTest);
 
   this->CTest->SetCTestConfigurationFromCMakeVariable(
@@ -46,9 +48,10 @@ cmCTestMemCheckCommand::InitializeActualHandler(HandlerArguments& args)
 }
 
 void cmCTestMemCheckCommand::ProcessAdditionalValues(
-  cmCTestGenericHandler* handler, HandlerArguments const& arguments)
+  cmCTestGenericHandler* handler, HandlerArguments const& arguments,
+  cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<MemCheckArguments const&>(arguments);
   if (!args.DefectCount.empty()) {
     mf.AddDefinition(

+ 3 - 2
Source/CTest/cmCTestMemCheckCommand.h

@@ -32,10 +32,11 @@ private:
   std::string GetName() const override { return "ctest_memcheck"; }
 
   std::unique_ptr<cmCTestTestHandler> InitializeActualHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   void ProcessAdditionalValues(cmCTestGenericHandler* handler,
-                               HandlerArguments const& arguments) override;
+                               HandlerArguments const& arguments,
+                               cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 6 - 4
Source/CTest/cmCTestReadCustomFilesCommand.cxx

@@ -3,19 +3,21 @@
 #include "cmCTestReadCustomFilesCommand.h"
 
 #include "cmCTest.h"
+#include "cmExecutionStatus.h"
 
-class cmExecutionStatus;
+class cmMakefile;
 
 bool cmCTestReadCustomFilesCommand::InitialPass(
-  std::vector<std::string> const& args, cmExecutionStatus& /*unused*/)
+  std::vector<std::string> const& args, cmExecutionStatus& status)
 {
   if (args.empty()) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
 
+  cmMakefile& mf = status.GetMakefile();
   for (std::string const& arg : args) {
-    this->CTest->ReadCustomConfigurationFileTree(arg, this->Makefile);
+    this->CTest->ReadCustomConfigurationFileTree(arg, &mf);
   }
 
   return true;

+ 4 - 4
Source/CTest/cmCTestRunScriptCommand.cxx

@@ -15,6 +15,7 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
     return false;
   }
 
+  cmMakefile& mf = status.GetMakefile();
   bool np = false;
   unsigned int i = 0;
   if (args[i] == "NEW_PROCESS") {
@@ -37,10 +38,9 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
       ++i;
     } else {
       int ret;
-      cmCTestScriptHandler::RunScript(this->CTest, this->Makefile,
-                                      cmSystemTools::CollapseFullPath(args[i]),
-                                      !np, &ret);
-      this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
+      cmCTestScriptHandler::RunScript(
+        this->CTest, &mf, cmSystemTools::CollapseFullPath(args[i]), !np, &ret);
+      mf.AddDefinition(returnVariable, std::to_string(ret));
     }
   }
   return true;

+ 29 - 27
Source/CTest/cmCTestStartCommand.cxx

@@ -7,19 +7,18 @@
 
 #include "cmCTest.h"
 #include "cmCTestVC.h"
+#include "cmExecutionStatus.h"
 #include "cmGeneratedFileStream.h"
 #include "cmMakefile.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmValue.h"
 
-class cmExecutionStatus;
-
 bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
-                                      cmExecutionStatus& /*unused*/)
+                                      cmExecutionStatus& status)
 {
   if (args.empty()) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
 
@@ -37,7 +36,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
           args[cnt] == "QUIET") {
         std::ostringstream e;
         e << args[cnt - 1] << " argument missing group name";
-        this->SetError(e.str());
+        status.SetError(e.str());
         return false;
       }
       this->CTest->SetSpecificGroup(args[cnt].c_str());
@@ -58,30 +57,33 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
       bld_dir = cmValue(args[cnt]);
       cnt++;
     } else {
-      this->SetError("Too many arguments");
+      status.SetError("Too many arguments");
       return false;
     }
   }
 
+  cmMakefile& mf = status.GetMakefile();
+
   if (!src_dir) {
-    src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
+    src_dir = mf.GetDefinition("CTEST_SOURCE_DIRECTORY");
   }
   if (!bld_dir) {
-    bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
+    bld_dir = mf.GetDefinition("CTEST_BINARY_DIRECTORY");
   }
   if (!src_dir) {
-    this->SetError("source directory not specified. Specify source directory "
-                   "as an argument or set CTEST_SOURCE_DIRECTORY");
+    status.SetError("source directory not specified. Specify source directory "
+                    "as an argument or set CTEST_SOURCE_DIRECTORY");
     return false;
   }
   if (!bld_dir) {
-    this->SetError("binary directory not specified. Specify binary directory "
-                   "as an argument or set CTEST_BINARY_DIRECTORY");
+    status.SetError("binary directory not specified. Specify binary directory "
+                    "as an argument or set CTEST_BINARY_DIRECTORY");
     return false;
   }
   if (!smodel && !append) {
-    this->SetError("no test model specified and APPEND not specified. Specify "
-                   "either a test model or the APPEND argument");
+    status.SetError(
+      "no test model specified and APPEND not specified. Specify "
+      "either a test model or the APPEND argument");
     return false;
   }
 
@@ -124,7 +126,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
   }
 
   // Make sure the source directory exists.
-  if (!this->InitialCheckout(ofs, sourceDir)) {
+  if (!this->InitialCheckout(ofs, sourceDir, status)) {
     return false;
   }
   if (!cmSystemTools::FileIsDirectory(sourceDir)) {
@@ -133,7 +135,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
       << "  " << sourceDir << "\n"
       << "which is not an existing directory.  "
       << "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
-    this->SetError(e.str());
+    status.SetError(e.str());
     return false;
   }
 
@@ -165,20 +167,20 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
     cmCTestOptionalLog(
       this->CTest, OUTPUT,
       "   Reading ctest configuration file: " << fname << std::endl, quiet);
-    bool readit = this->Makefile->ReadDependentFile(fname);
+    bool readit = mf.ReadDependentFile(fname);
     if (!readit) {
       std::string m = cmStrCat("Could not find include file: ", fname);
-      this->SetError(m);
+      status.SetError(m);
       return false;
     }
   }
 
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME", quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "Site",
+    &mf, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME", quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(&mf, "Site",
                                                       "CTEST_SITE", quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(
-    this->Makefile, "BuildName", "CTEST_BUILD_NAME", quiet);
+    &mf, "BuildName", "CTEST_BUILD_NAME", quiet);
 
   this->CTest->Initialize(bld_dir);
   this->CTest->UpdateCTestConfiguration();
@@ -203,7 +205,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
     return false;
   }
 
-  this->CTest->ReadCustomConfigurationFileTree(bld_dir, this->Makefile);
+  this->CTest->ReadCustomConfigurationFileTree(bld_dir, &mf);
 
   if (append) {
     if (!this->CTest->ReadExistingTag(quiet)) {
@@ -223,14 +225,14 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
 }
 
 bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs,
-                                          std::string const& sourceDir)
+                                          std::string const& sourceDir,
+                                          cmExecutionStatus& status)
 {
+  cmMakefile& mf = status.GetMakefile();
   // Use the user-provided command to create the source tree.
-  cmValue initialCheckoutCommand =
-    this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
+  cmValue initialCheckoutCommand = mf.GetDefinition("CTEST_CHECKOUT_COMMAND");
   if (!initialCheckoutCommand) {
-    initialCheckoutCommand =
-      this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
+    initialCheckoutCommand = mf.GetDefinition("CTEST_CVS_CHECKOUT");
   }
   if (initialCheckoutCommand) {
     // Use a generic VC object to run and log the command.

+ 2 - 1
Source/CTest/cmCTestStartCommand.h

@@ -42,5 +42,6 @@ public:
                    cmExecutionStatus& status) override;
 
 private:
-  bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir);
+  bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir,
+                       cmExecutionStatus& status);
 };

+ 10 - 9
Source/CTest/cmCTestSubmitCommand.cxx

@@ -15,6 +15,7 @@
 #include "cmCTestGenericHandler.h"
 #include "cmCTestSubmitHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmList.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
@@ -22,8 +23,6 @@
 #include "cmSystemTools.h"
 #include "cmValue.h"
 
-class cmExecutionStatus;
-
 std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
 {
   auto ni = cm::make_unique<cmCTestSubmitCommand>();
@@ -32,9 +31,9 @@ std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
 }
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler(
-  HandlerArguments& arguments)
+  HandlerArguments& arguments, cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<SubmitArguments&>(arguments);
   cmValue submitURL = !args.SubmitURL.empty()
     ? cmValue(args.SubmitURL)
@@ -113,7 +112,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestSubmitCommand::InitializeHandler(
   if (extraFilesVariable) {
     cmList extraFiles{ *extraFilesVariable };
     if (!this->CTest->SubmitExtraFiles(extraFiles)) {
-      this->SetError("problem submitting extra files.");
+      status.SetError("problem submitting extra files.");
       return nullptr;
     }
   }
@@ -208,9 +207,10 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
   });
 }
 
-void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments)
+void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments,
+                                          cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto& args = static_cast<SubmitArguments&>(arguments);
   if (args.Parts) {
     cm::erase_if(*(args.Parts), [this, &mf](std::string const& arg) -> bool {
@@ -240,9 +240,10 @@ void cmCTestSubmitCommand::CheckArguments(HandlerArguments& arguments)
 }
 
 void cmCTestSubmitCommand::ProcessAdditionalValues(
-  cmCTestGenericHandler*, HandlerArguments const& arguments)
+  cmCTestGenericHandler*, HandlerArguments const& arguments,
+  cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto const& args = static_cast<SubmitArguments const&>(arguments);
   if (!args.BuildID.empty()) {
     mf.AddDefinition(args.BuildID, this->CTest->GetBuildID());

+ 5 - 3
Source/CTest/cmCTestSubmitCommand.h

@@ -45,13 +45,15 @@ private:
 
   std::string GetName() const override { return "ctest_submit"; }
 
-  void CheckArguments(HandlerArguments& arguments) override;
+  void CheckArguments(HandlerArguments& arguments,
+                      cmExecutionStatus& status) override;
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   void ProcessAdditionalValues(cmCTestGenericHandler* handler,
-                               HandlerArguments const& arguments) override;
+                               HandlerArguments const& arguments,
+                               cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 6 - 6
Source/CTest/cmCTestTestCommand.cxx

@@ -16,12 +16,11 @@
 #include "cmCTestTestHandler.h"
 #include "cmCommand.h"
 #include "cmDuration.h"
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmStringAlgorithms.h"
 #include "cmValue.h"
 
-class cmExecutionStatus;
-
 std::unique_ptr<cmCommand> cmCTestTestCommand::Clone()
 {
   auto ni = cm::make_unique<cmCTestTestCommand>();
@@ -30,9 +29,9 @@ std::unique_ptr<cmCommand> cmCTestTestCommand::Clone()
 }
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
-  HandlerArguments& arguments)
+  HandlerArguments& arguments, cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto& args = static_cast<TestArguments&>(arguments);
   cmValue ctestTimeout = mf.GetDefinition("CTEST_TEST_TIMEOUT");
 
@@ -53,7 +52,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
     args.ResourceSpecFile = *resourceSpecFile;
   }
 
-  auto handler = this->InitializeActualHandler(args);
+  auto handler = this->InitializeActualHandler(args, status);
   if (!args.Start.empty() || !args.End.empty() || !args.Stride.empty()) {
     handler->TestOptions.TestsToRunInformation =
       cmStrCat(args.Start, ',', args.End, ',', args.Stride);
@@ -148,7 +147,8 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestTestCommand::InitializeHandler(
 }
 
 std::unique_ptr<cmCTestTestHandler>
-cmCTestTestCommand::InitializeActualHandler(HandlerArguments&)
+cmCTestTestCommand::InitializeActualHandler(HandlerArguments&,
+                                            cmExecutionStatus&)
 {
   return cm::make_unique<cmCTestTestHandler>(this->CTest);
 }

+ 2 - 2
Source/CTest/cmCTestTestCommand.h

@@ -84,10 +84,10 @@ private:
   std::string GetName() const override { return "ctest_test"; }
 
   virtual std::unique_ptr<cmCTestTestHandler> InitializeActualHandler(
-    HandlerArguments& arguments);
+    HandlerArguments& arguments, cmExecutionStatus& status);
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 4 - 3
Source/CTest/cmCTestUpdateCommand.cxx

@@ -10,6 +10,7 @@
 #include "cmCTestGenericHandler.h"
 #include "cmCTestUpdateHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
 
@@ -21,9 +22,9 @@ std::unique_ptr<cmCommand> cmCTestUpdateCommand::Clone()
 }
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestUpdateCommand::InitializeHandler(
-  HandlerArguments& args)
+  HandlerArguments& args, cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   if (!args.Source.empty()) {
     this->CTest->SetCTestConfiguration(
       "SourceDirectory", cmSystemTools::CollapseFullPath(args.Source),
@@ -83,7 +84,7 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestUpdateCommand::InitializeHandler(
 
   auto handler = cm::make_unique<cmCTestUpdateHandler>(this->CTest);
   if (source_dir.empty()) {
-    this->SetError("source directory not specified. Please use SOURCE tag");
+    status.SetError("source directory not specified. Please use SOURCE tag");
     return nullptr;
   }
   handler->SourceDirectory = source_dir;

+ 1 - 1
Source/CTest/cmCTestUpdateCommand.h

@@ -25,7 +25,7 @@ private:
   std::string GetName() const override { return "ctest_update"; }
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& args) override;
+    HandlerArguments& args, cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;

+ 5 - 5
Source/CTest/cmCTestUploadCommand.cxx

@@ -14,12 +14,11 @@
 #include "cmCTestGenericHandler.h"
 #include "cmCTestUploadHandler.h"
 #include "cmCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
 #include "cmSystemTools.h"
 
-class cmExecutionStatus;
-
 std::unique_ptr<cmCommand> cmCTestUploadCommand::Clone()
 {
   auto ni = cm::make_unique<cmCTestUploadCommand>();
@@ -27,9 +26,10 @@ std::unique_ptr<cmCommand> cmCTestUploadCommand::Clone()
   return std::unique_ptr<cmCommand>(std::move(ni));
 }
 
-void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments)
+void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments,
+                                          cmExecutionStatus& status)
 {
-  cmMakefile& mf = *this->Makefile;
+  cmMakefile& mf = status.GetMakefile();
   auto& args = static_cast<UploadArguments&>(arguments);
   cm::erase_if(args.Files, [&mf](std::string const& arg) -> bool {
     if (!cmSystemTools::FileExists(arg)) {
@@ -44,7 +44,7 @@ void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments)
 }
 
 std::unique_ptr<cmCTestGenericHandler> cmCTestUploadCommand::InitializeHandler(
-  HandlerArguments& arguments)
+  HandlerArguments& arguments, cmExecutionStatus&)
 {
   auto const& args = static_cast<UploadArguments&>(arguments);
   auto handler = cm::make_unique<cmCTestUploadHandler>(this->CTest);

+ 3 - 2
Source/CTest/cmCTestUploadCommand.h

@@ -31,10 +31,11 @@ private:
 
   std::string GetName() const override { return "ctest_upload"; }
 
-  void CheckArguments(HandlerArguments& arguments) override;
+  void CheckArguments(HandlerArguments& arguments,
+                      cmExecutionStatus& status) override;
 
   std::unique_ptr<cmCTestGenericHandler> InitializeHandler(
-    HandlerArguments& arguments) override;
+    HandlerArguments& arguments, cmExecutionStatus& status) override;
 
   bool InitialPass(std::vector<std::string> const& args,
                    cmExecutionStatus& status) override;