diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index aca5d79b96..0f81f331b1 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -190,7 +190,7 @@ bool cmCTestStartCommand::InitialPass(std::vector 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, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 3e4013832a..f5be94727d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -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(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(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 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); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index b402135289..c7c7a72f2a 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -69,13 +69,8 @@ public: /** Process Command line arguments */ int Run(std::vector 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);