cmCTest*Command: Bring all classes to a uniform layout

Make sure that all classes have a public inherited constructor, protected
data members for the arguments, followed by other private virtual functions.
The intention is to make following changes to have a smaller diff.
This commit is contained in:
Daniel Pfeifer
2024-10-27 00:46:45 +02:00
parent 73830f976a
commit c1de0976f8
18 changed files with 182 additions and 218 deletions
-2
View File
@@ -39,8 +39,6 @@ void cmCTestBuildCommand::BindArguments()
this->Bind("PARALLEL_LEVEL"_s, this->ParallelLevel);
}
cmCTestBuildCommand::~cmCTestBuildCommand() = default;
std::unique_ptr<cmCTestGenericHandler> cmCTestBuildCommand::InitializeHandler()
{
auto handler = cm::make_unique<cmCTestBuildHandler>(this->CTest);
+11 -20
View File
@@ -9,34 +9,16 @@
#include "cmCTestHandlerCommand.h"
class cmCommand;
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestBuild
* \brief Run a ctest script
*
* cmCTestBuildCommand defineds the command to build the project.
*/
class cmCTestBuildCommand : public cmCTestHandlerCommand
{
public:
~cmCTestBuildCommand() override;
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override;
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_build"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void ProcessAdditionalValues(cmCTestGenericHandler* handler) override;
void BindArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
std::string NumberErrors;
std::string NumberWarnings;
std::string Target;
@@ -44,4 +26,13 @@ protected:
std::string Flags;
std::string ProjectName;
std::string ParallelLevel;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_build"; }
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
void ProcessAdditionalValues(cmCTestGenericHandler* handler) override;
};
+10
View File
@@ -4,13 +4,16 @@
#include <cstring>
#include <sstream>
#include <utility>
#include <vector>
#include <cm/memory>
#include <cmext/string_view>
#include "cmCTest.h"
#include "cmCTestConfigureHandler.h"
#include "cmCTestGenericHandler.h"
#include "cmCommand.h"
#include "cmGlobalGenerator.h"
#include "cmList.h"
#include "cmMakefile.h"
@@ -19,6 +22,13 @@
#include "cmValue.h"
#include "cmake.h"
std::unique_ptr<cmCommand> cmCTestConfigureCommand::Clone()
{
auto ni = cm::make_unique<cmCTestConfigureCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
void cmCTestConfigureCommand::BindArguments()
{
this->cmCTestHandlerCommand::BindArguments();
+10 -25
View File
@@ -4,42 +4,27 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <cm/memory>
#include "cmCTestHandlerCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestConfigure
* \brief Run a ctest script
*
* cmCTestConfigureCommand defineds the command to configures the project.
*/
class cmCTestConfigureCommand : public cmCTestHandlerCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestConfigureCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_configure"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void BindArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
std::string Options;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_configure"; }
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
};
+10
View File
@@ -3,12 +3,22 @@
#include "cmCTestCoverageCommand.h"
#include <set>
#include <utility>
#include <cm/memory>
#include <cmext/string_view>
#include "cmCTest.h"
#include "cmCTestCoverageHandler.h"
#include "cmCTestGenericHandler.h"
#include "cmCommand.h"
std::unique_ptr<cmCommand> cmCTestCoverageCommand::Clone()
{
auto ni = cm::make_unique<cmCTestCoverageCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
void cmCTestCoverageCommand::BindArguments()
{
+10 -24
View File
@@ -4,45 +4,31 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <cm/memory>
#include <cm/optional>
#include "cmArgumentParserTypes.h" // IWYU pragma: keep
#include "cmCTestHandlerCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestCoverage
* \brief Run a ctest script
*
* cmCTestCoverageCommand defineds the command to test the project.
*/
class cmCTestCoverageCommand : public cmCTestHandlerCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestCoverageCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_coverage"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void BindArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> Labels;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_coverage"; }
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
};
+10
View File
@@ -242,3 +242,13 @@ void cmCTestHandlerCommand::BindArguments()
void cmCTestHandlerCommand::CheckArguments()
{
}
std::unique_ptr<cmCTestGenericHandler>
cmCTestHandlerCommand::InitializeHandler()
{
return nullptr;
};
void cmCTestHandlerCommand::ProcessAdditionalValues(cmCTestGenericHandler*)
{
}
+14 -23
View File
@@ -16,37 +16,15 @@
class cmCTestGenericHandler;
class cmExecutionStatus;
/** \class cmCTestHandler
* \brief Run a ctest script
*
* cmCTestHandlerCommand defineds the command to test the project.
*/
class cmCTestHandlerCommand
: public cmCTestCommand
, public cmArgumentParser<void>
{
public:
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual std::string GetName() const = 0;
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
using cmCTestCommand::cmCTestCommand;
protected:
virtual std::unique_ptr<cmCTestGenericHandler> InitializeHandler() = 0;
virtual void ProcessAdditionalValues(cmCTestGenericHandler* /*handler*/) {}
// Command argument handling.
virtual void BindArguments();
virtual void CheckArguments();
std::vector<cm::string_view> ParsedKeywords;
bool Append = false;
bool Quiet = false;
@@ -55,4 +33,17 @@ protected:
std::string Build;
std::string Source;
std::string SubmitIndex;
protected:
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
private:
virtual std::string GetName() const = 0;
virtual void CheckArguments();
virtual std::unique_ptr<cmCTestGenericHandler> InitializeHandler();
virtual void ProcessAdditionalValues(cmCTestGenericHandler*);
};
+11
View File
@@ -2,13 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestMemCheckCommand.h"
#include <utility>
#include <cm/memory>
#include <cmext/string_view>
#include "cmCTest.h"
#include "cmCTestMemCheckHandler.h"
#include "cmCTestTestHandler.h"
#include "cmCommand.h"
#include "cmMakefile.h"
std::unique_ptr<cmCommand> cmCTestMemCheckCommand::Clone()
{
auto ni = cm::make_unique<cmCTestMemCheckCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
void cmCTestMemCheckCommand::BindArguments()
{
this->cmCTestTestCommand::BindArguments();
+9 -20
View File
@@ -4,41 +4,30 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <cm/memory>
#include "cmCTestTestCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCTestTestHandler;
class cmCommand;
/** \class cmCTestMemCheck
* \brief Run a ctest script
*
* cmCTestMemCheckCommand defineds the command to test the project.
*/
class cmCTestMemCheckCommand : public cmCTestTestCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestMemCheckCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
using cmCTestTestCommand::cmCTestTestCommand;
protected:
void BindArguments() override;
std::string DefectCount;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_memcheck"; }
std::unique_ptr<cmCTestTestHandler> InitializeActualHandler() override;
void ProcessAdditionalValues(cmCTestGenericHandler* handler) override;
std::string DefectCount;
};
+8 -10
View File
@@ -23,9 +23,6 @@
class cmExecutionStatus;
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
{
auto ni = cm::make_unique<cmCTestSubmitCommand>();
@@ -185,13 +182,7 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
{
this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD";
bool ret = this->cmCTestHandlerCommand::InitialPass(args, status);
if (!this->BuildID.empty()) {
this->Makefile->AddDefinition(this->BuildID, this->CTest->GetBuildID());
}
return ret;
return this->cmCTestHandlerCommand::InitialPass(args, status);
}
void cmCTestSubmitCommand::BindArguments()
@@ -245,3 +236,10 @@ void cmCTestSubmitCommand::CheckArguments()
});
}
}
void cmCTestSubmitCommand::ProcessAdditionalValues(cmCTestGenericHandler*)
{
if (!this->BuildID.empty()) {
this->Makefile->AddDefinition(this->BuildID, this->CTest->GetBuildID());
}
}
+17 -20
View File
@@ -13,34 +13,17 @@
#include "cmArgumentParserTypes.h"
#include "cmCTestHandlerCommand.h"
class cmCommand;
class cmCTestGenericHandler;
class cmExecutionStatus;
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestSubmit
* \brief Run a ctest script
*
* cmCTestSubmitCommand defineds the command to submit the test results for
* the project.
*/
class cmCTestSubmitCommand : public cmCTestHandlerCommand
{
public:
std::unique_ptr<cmCommand> Clone() override;
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_submit"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void BindArguments() override;
void CheckArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
bool CDashUpload = false;
bool InternalTest = false;
@@ -54,4 +37,18 @@ protected:
cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> Files;
ArgumentParser::MaybeEmpty<std::vector<std::string>> HttpHeaders;
cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> Parts;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_submit"; }
void CheckArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
void ProcessAdditionalValues(cmCTestGenericHandler* handler) override;
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
+10
View File
@@ -6,18 +6,28 @@
#include <cstdlib>
#include <ratio>
#include <sstream>
#include <utility>
#include <vector>
#include <cm/memory>
#include <cmext/string_view>
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestTestHandler.h"
#include "cmCommand.h"
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmValue.h"
std::unique_ptr<cmCommand> cmCTestTestCommand::Clone()
{
auto ni = cm::make_unique<cmCTestTestCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
void cmCTestTestCommand::BindArguments()
{
this->cmCTestHandlerCommand::BindArguments();
+12 -25
View File
@@ -4,47 +4,25 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <cm/memory>
#include <cm/optional>
#include "cmArgumentParserTypes.h"
#include "cmCTestHandlerCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCTestTestHandler;
class cmCommand;
/** \class cmCTestTest
* \brief Run a ctest script
*
* cmCTestTestCommand defineds the command to test the project.
*/
class cmCTestTestCommand : public cmCTestHandlerCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestTestCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_test"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void BindArguments() override;
virtual std::unique_ptr<cmCTestTestHandler> InitializeActualHandler();
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
std::string Start;
std::string End;
std::string Stride;
@@ -65,4 +43,13 @@ protected:
std::string ResourceSpecFile;
std::string OutputJUnit;
bool StopOnFailure = false;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_test"; }
virtual std::unique_ptr<cmCTestTestHandler> InitializeActualHandler();
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
};
+12
View File
@@ -2,12 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUpdateCommand.h"
#include <utility>
#include <cm/memory>
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestUpdateHandler.h"
#include "cmCommand.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
std::unique_ptr<cmCommand> cmCTestUpdateCommand::Clone()
{
auto ni = cm::make_unique<cmCTestUpdateCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
std::unique_ptr<cmCTestGenericHandler>
cmCTestUpdateCommand::InitializeHandler()
{
+6 -22
View File
@@ -4,39 +4,23 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <cm/memory>
#include "cmCTestHandlerCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestUpdate
* \brief Run a ctest script
*
* cmCTestUpdateCommand defineds the command to updates the repository.
*/
class cmCTestUpdateCommand : public cmCTestHandlerCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestUpdateCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
using cmCTestHandlerCommand::cmCTestHandlerCommand;
private:
std::unique_ptr<cmCommand> Clone() override;
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_update"; }
protected:
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
};
+10
View File
@@ -4,16 +4,26 @@
#include <set>
#include <sstream>
#include <utility>
#include <cm/memory>
#include <cm/vector>
#include <cmext/string_view>
#include "cmCTestGenericHandler.h"
#include "cmCTestUploadHandler.h"
#include "cmCommand.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmSystemTools.h"
std::unique_ptr<cmCommand> cmCTestUploadCommand::Clone()
{
auto ni = cm::make_unique<cmCTestUploadCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
void cmCTestUploadCommand::BindArguments()
{
this->Bind("FILES"_s, this->Files);
+12 -27
View File
@@ -4,46 +4,31 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <cm/memory>
#include "cmArgumentParserTypes.h"
#include "cmCTestHandlerCommand.h"
#include "cmCommand.h"
class cmCTestGenericHandler;
class cmCommand;
/** \class cmCTestUpload
* \brief Run a ctest script
*
* cmCTestUploadCommand defines the command to upload result files for
* the project.
*/
class cmCTestUploadCommand : public cmCTestHandlerCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std::unique_ptr<cmCommand> Clone() override
{
auto ni = cm::make_unique<cmCTestUploadCommand>();
ni->CTest = this->CTest;
return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
std::string GetName() const override { return "ctest_upload"; }
using cmCTestHandlerCommand::cmCTestHandlerCommand;
protected:
void BindArguments() override;
void CheckArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
ArgumentParser::MaybeEmpty<std::vector<std::string>> Files;
private:
std::unique_ptr<cmCommand> Clone() override;
std::string GetName() const override { return "ctest_upload"; }
void CheckArguments() override;
std::unique_ptr<cmCTestGenericHandler> InitializeHandler() override;
};