cmCTest: Separate initialization of script and command line

This commit is contained in:
Daniel Pfeifer
2024-10-17 20:26:56 +02:00
committed by Brad King
parent 402af107a5
commit 0bfe17e15b
3 changed files with 36 additions and 38 deletions

View File

@@ -190,7 +190,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "BuildName", "CTEST_BUILD_NAME", this->Quiet);
if (!this->CTest->Initialize(bld_dir, this)) {
if (!this->CTest->Initialize(bld_dir, *this)) {
return false;
}
cmCTestOptionalLog(this->CTest, OUTPUT,

View File

@@ -417,15 +417,13 @@ cmCTest::Part cmCTest::GetPartFromName(const std::string& name)
}
bool cmCTest::Initialize(const std::string& binary_dir,
cmCTestStartCommand* command)
cmCTestStartCommand& command)
{
bool quiet = false;
if (command) {
this->Impl->BuildID = "";
for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) {
this->Impl->Parts[p].SubmitFiles.clear();
}
quiet = command->ShouldBeQuiet();
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);
@@ -462,26 +460,13 @@ bool cmCTest::Initialize(const std::string& binary_dir,
return 0;
}
cmake cm(cmake::RoleScript, cmState::CTest);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
cmMakefile mf(&gg, cm.GetCurrentSnapshot());
this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, &mf);
cmMakefile* mf = command.GetMakefile();
this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, mf);
if (command) {
if (command->ShouldCreateNewTag()) {
return this->CreateNewTag(quiet);
}
return this->ReadExistingTag(quiet);
}
if (this->Impl->Parts[PartStart]) {
if (command.ShouldCreateNewTag()) {
return this->CreateNewTag(quiet);
}
return this->ReadExistingTag(true) || this->CreateNewTag(quiet);
return this->ReadExistingTag(quiet);
}
bool cmCTest::CreateNewTag(bool quiet)
@@ -878,23 +863,41 @@ int cmCTest::ProcessSteps()
return 1;
}
if (!this->Initialize(workDir, nullptr)) {
cmCTestLog(this, ERROR_MESSAGE,
"Problem initializing the dashboard." << std::endl);
return 12;
}
this->Impl->BinaryDir = workDir;
cmSystemTools::ConvertToUnixSlashes(this->Impl->BinaryDir);
this->UpdateCTestConfiguration();
this->BlockTestErrorDiagnostics();
int res = 0;
cmCTestScriptHandler script;
script.SetCTestInstance(this);
script.CreateCMake();
cmMakefile& mf = *script.GetMakefile();
this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir, &mf);
this->SetCMakeVariables(mf);
std::vector<cmListFileArgument> args{
cmListFileArgument("RETURN_VALUE", cmListFileArgument::Unquoted, 0),
cmListFileArgument("return_value", cmListFileArgument::Unquoted, 0),
};
if (this->Impl->Parts[PartStart]) {
auto const func = cmListFileFunction(
"ctest_start", 0, 0,
{
{ this->GetTestModelString(), cmListFileArgument::Unquoted, 0 },
{ "GROUP", cmListFileArgument::Unquoted, 0 },
{ this->GetTestGroupString(), cmListFileArgument::Unquoted, 0 },
});
auto status = cmExecutionStatus(mf);
if (!mf.ExecuteCommand(func, status)) {
return 12;
}
} else if (!this->ReadExistingTag(true) && !this->CreateNewTag(false)) {
cmCTestLog(this, ERROR_MESSAGE,
"Problem initializing the dashboard." << std::endl);
return 12;
}
if (this->Impl->Parts[PartUpdate] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
auto const func = cmListFileFunction("ctest_update", 0, 0, args);

View File

@@ -69,13 +69,8 @@ public:
/** Process Command line arguments */
int Run(std::vector<std::string> const& args);
/**
* Initialize a dashboard run in the given build tree. The "command"
* argument is non-NULL when running from a command-driven (ctest_start)
* dashboard script, and NULL when running from the CTest command
* line.
*/
bool Initialize(const std::string& binary_dir, cmCTestStartCommand* command);
/** Initialize a dashboard run in the given build tree. */
bool Initialize(const std::string& binary_dir, cmCTestStartCommand& command);
bool CreateNewTag(bool quiet);
bool ReadExistingTag(bool quiet);