cmCTestStartCommand: Remove data members

This commit is contained in:
Daniel Pfeifer
2024-10-17 22:27:45 +02:00
committed by Brad King
parent 0bfe17e15b
commit 80d6b20657
4 changed files with 56 additions and 85 deletions

View File

@@ -15,12 +15,6 @@
class cmExecutionStatus;
cmCTestStartCommand::cmCTestStartCommand()
{
this->CreateNewTag = true;
this->Quiet = false;
}
bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& /*unused*/)
{
@@ -30,6 +24,8 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
}
size_t cnt = 0;
bool append = false;
bool quiet = false;
const char* smodel = nullptr;
cmValue src_dir;
cmValue bld_dir;
@@ -48,10 +44,10 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
cnt++;
} else if (args[cnt] == "APPEND") {
cnt++;
this->CreateNewTag = false;
append = true;
} else if (args[cnt] == "QUIET") {
cnt++;
this->Quiet = true;
quiet = true;
} else if (!smodel) {
smodel = args[cnt].c_str();
cnt++;
@@ -83,7 +79,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
"as an argument or set CTEST_BINARY_DIRECTORY");
return false;
}
if (!smodel && this->CreateNewTag) {
if (!smodel && !append) {
this->SetError("no test model specified and APPEND not specified. Specify "
"either a test model or the APPEND argument");
return false;
@@ -96,9 +92,8 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
std::string sourceDir = cmSystemTools::CollapseFullPath(*src_dir);
std::string binaryDir = cmSystemTools::CollapseFullPath(*bld_dir);
this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir,
this->Quiet);
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir, this->Quiet);
this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir, quiet);
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir, quiet);
if (smodel) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
@@ -106,7 +101,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
<< smodel << std::endl
<< " Source directory: " << *src_dir << std::endl
<< " Build directory: " << *bld_dir << std::endl,
this->Quiet);
quiet);
} else {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"Run dashboard with "
@@ -114,12 +109,12 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
<< std::endl
<< " Source directory: " << *src_dir << std::endl
<< " Build directory: " << *bld_dir << std::endl,
this->Quiet);
quiet);
}
const char* group = this->CTest->GetSpecificGroup();
if (group) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Group: " << group << std::endl, this->Quiet);
" Group: " << group << std::endl, quiet);
}
// Log startup actions.
@@ -170,10 +165,9 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
}
if (!fname.empty()) {
cmCTestOptionalLog(this->CTest, OUTPUT,
" Reading ctest configuration file: " << fname
<< std::endl,
this->Quiet);
cmCTestOptionalLog(
this->CTest, OUTPUT,
" Reading ctest configuration file: " << fname << std::endl, quiet);
bool readit = this->Makefile->ReadDependentFile(fname);
if (!readit) {
std::string m = cmStrCat("Could not find include file: ", fname);
@@ -183,20 +177,51 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
}
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME",
this->Quiet);
this->Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME", quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "Site",
"CTEST_SITE", quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "Site", "CTEST_SITE", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "BuildName", "CTEST_BUILD_NAME", this->Quiet);
this->Makefile, "BuildName", "CTEST_BUILD_NAME", quiet);
if (!this->CTest->Initialize(bld_dir, *this)) {
this->CTest->Initialize(bld_dir);
this->CTest->UpdateCTestConfiguration();
cmCTestOptionalLog(
this->CTest, OUTPUT,
" Site: " << this->CTest->GetCTestConfiguration("Site") << std::endl
<< " Build name: "
<< cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName"))
<< std::endl,
quiet);
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY &&
this->CTest->GetCTestConfiguration("NightlyStartTime").empty()) {
cmCTestOptionalLog(
this->CTest, WARNING,
"WARNING: No nightly start time found please set in CTestConfig.cmake"
" or DartConfig.cmake"
<< std::endl,
quiet);
return false;
}
this->CTest->ReadCustomConfigurationFileTree(bld_dir, this->Makefile);
if (append) {
if (!this->CTest->ReadExistingTag(quiet)) {
return false;
}
} else {
if (!this->CTest->CreateNewTag(quiet)) {
return false;
}
}
cmCTestOptionalLog(this->CTest, OUTPUT,
" Use " << this->CTest->GetTestGroupString() << " tag: "
<< this->CTest->GetCurrentTag() << std::endl,
this->Quiet);
quiet);
return true;
}

View File

@@ -24,8 +24,6 @@ class cmExecutionStatus;
class cmCTestStartCommand : public cmCTestCommand
{
public:
cmCTestStartCommand();
/**
* This is a virtual constructor for the command.
*/
@@ -33,8 +31,6 @@ public:
{
auto ni = cm::make_unique<cmCTestStartCommand>();
ni->CTest = this->CTest;
ni->CreateNewTag = this->CreateNewTag;
ni->Quiet = this->Quiet;
return std::unique_ptr<cmCommand>(std::move(ni));
}
@@ -45,18 +41,6 @@ public:
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
/**
* Will this invocation of ctest_start create a new TAG file?
*/
bool ShouldCreateNewTag() { return this->CreateNewTag; }
/**
* Should this invocation of ctest_start output non-error messages?
*/
bool ShouldBeQuiet() { return this->Quiet; }
private:
bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir);
bool CreateNewTag;
bool Quiet;
};

View File

@@ -48,7 +48,6 @@
#include "cmCTestGenericHandler.h"
#include "cmCTestMemCheckHandler.h"
#include "cmCTestScriptHandler.h"
#include "cmCTestStartCommand.h"
#include "cmCTestSubmitHandler.h"
#include "cmCTestTestHandler.h"
#include "cmCTestUpdateHandler.h"
@@ -416,17 +415,13 @@ cmCTest::Part cmCTest::GetPartFromName(const std::string& name)
return PartCount;
}
bool cmCTest::Initialize(const std::string& binary_dir,
cmCTestStartCommand& command)
void cmCTest::Initialize(std::string const& binary_dir)
{
bool const quiet = command.ShouldBeQuiet();
this->Impl->BuildID = "";
for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) {
this->Impl->Parts[p].SubmitFiles.clear();
}
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
if (!this->Impl->InteractiveDebugMode) {
this->BlockTestErrorDiagnostics();
} else {
@@ -435,38 +430,6 @@ bool cmCTest::Initialize(const std::string& binary_dir,
this->Impl->BinaryDir = binary_dir;
cmSystemTools::ConvertToUnixSlashes(this->Impl->BinaryDir);
this->UpdateCTestConfiguration();
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
cmCTestOptionalLog(this, OUTPUT,
" Site: " << this->GetCTestConfiguration("Site")
<< std::endl
<< " Build name: "
<< cmCTest::SafeBuildIdField(
this->GetCTestConfiguration("BuildName"))
<< std::endl,
quiet);
cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet);
if (this->Impl->TestModel == cmCTest::NIGHTLY &&
this->GetCTestConfiguration("NightlyStartTime").empty()) {
cmCTestOptionalLog(
this, WARNING,
"WARNING: No nightly start time found please set in CTestConfig.cmake"
" or DartConfig.cmake"
<< std::endl,
quiet);
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
return 0;
}
cmMakefile* mf = command.GetMakefile();
this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, mf);
if (command.ShouldCreateNewTag()) {
return this->CreateNewTag(quiet);
}
return this->ReadExistingTag(quiet);
}
bool cmCTest::CreateNewTag(bool quiet)

View File

@@ -28,7 +28,6 @@ class cmCTestConfigureHandler;
class cmCTestMemCheckHandler;
class cmCTestSubmitHandler;
class cmCTestUploadHandler;
class cmCTestStartCommand;
class cmGeneratedFileStream;
class cmMakefile;
class cmXMLWriter;
@@ -70,7 +69,7 @@ public:
int Run(std::vector<std::string> const& args);
/** Initialize a dashboard run in the given build tree. */
bool Initialize(const std::string& binary_dir, cmCTestStartCommand& command);
void Initialize(std::string const& binary_dir);
bool CreateNewTag(bool quiet);
bool ReadExistingTag(bool quiet);
@@ -442,6 +441,9 @@ public:
void GenerateSubprojectsOutput(cmXMLWriter& xml);
std::vector<std::string> GetLabelsForSubprojects();
/** Reread the configuration file */
bool UpdateCTestConfiguration();
private:
void SetPersistentOptionIfNotEmpty(const std::string& value,
const std::string& optionName);
@@ -475,9 +477,6 @@ private:
/** returns true iff the console supports colored output */
static bool ColoredOutputSupportedByConsole();
/** Reread the configuration file */
bool UpdateCTestConfiguration();
/** Create note from files. */
int GenerateCTestNotesOutput(cmXMLWriter& xml,
std::vector<std::string> const& files);