1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

cmCTestStartCommand: Inline InitializeFromCommand function

This commit is contained in:
Daniel Pfeifer
2024-10-17 11:08:16 +02:00
committed by Brad King
parent 9fbdfa11d4
commit 3c321b6571
3 changed files with 55 additions and 70 deletions

View File

@@ -9,6 +9,7 @@
#include "cmCTestVC.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmValue.h"
@@ -154,7 +155,49 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
this->CTest->SetTestModel(model);
this->CTest->SetProduceXML(true);
return this->CTest->InitializeFromCommand(this);
std::string fname;
std::string src_dir_fname = cmStrCat(sourceDir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(src_dir_fname);
std::string bld_dir_fname = cmStrCat(binaryDir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
if (cmSystemTools::FileExists(bld_dir_fname)) {
fname = bld_dir_fname;
} else if (cmSystemTools::FileExists(src_dir_fname)) {
fname = src_dir_fname;
}
if (!fname.empty()) {
cmCTestOptionalLog(this->CTest, OUTPUT,
" Reading ctest configuration file: " << fname
<< std::endl,
this->Quiet);
bool readit = this->Makefile->ReadDependentFile(fname);
if (!readit) {
std::string m = cmStrCat("Could not find include file: ", fname);
this->SetError(m);
return false;
}
}
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "Site", "CTEST_SITE", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "BuildName", "CTEST_BUILD_NAME", this->Quiet);
if (!this->CTest->Initialize(bld_dir, this)) {
return false;
}
cmCTestOptionalLog(this->CTest, OUTPUT,
" Use " << this->CTest->GetTestModelString() << " tag: "
<< this->CTest->GetCurrentTag() << std::endl,
this->Quiet);
return true;
}
bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs,

View File

@@ -420,8 +420,12 @@ int cmCTest::Initialize(const std::string& binary_dir,
cmCTestStartCommand* command)
{
bool quiet = false;
if (command && command->ShouldBeQuiet()) {
quiet = true;
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();
}
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
@@ -644,61 +648,6 @@ int cmCTest::Initialize(const std::string& binary_dir,
return 1;
}
bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{
std::string src_dir = this->GetCTestConfiguration("SourceDirectory");
std::string bld_dir = this->GetCTestConfiguration("BuildDirectory");
this->Impl->BuildID = "";
for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) {
this->Impl->Parts[p].SubmitFiles.clear();
}
cmMakefile* mf = command->GetMakefile();
std::string fname;
std::string src_dir_fname = cmStrCat(src_dir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(src_dir_fname);
std::string bld_dir_fname = cmStrCat(bld_dir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
if (cmSystemTools::FileExists(bld_dir_fname)) {
fname = bld_dir_fname;
} else if (cmSystemTools::FileExists(src_dir_fname)) {
fname = src_dir_fname;
}
if (!fname.empty()) {
cmCTestOptionalLog(this, OUTPUT,
" Reading ctest configuration file: " << fname
<< std::endl,
command->ShouldBeQuiet());
bool readit = mf->ReadDependentFile(fname);
if (!readit) {
std::string m = cmStrCat("Could not find include file: ", fname);
command->SetError(m);
return false;
}
}
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
"CTEST_NIGHTLY_START_TIME",
command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE",
command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(
mf, "BuildName", "CTEST_BUILD_NAME", command->ShouldBeQuiet());
if (!this->Initialize(bld_dir, command)) {
return false;
}
cmCTestOptionalLog(this, OUTPUT,
" Use " << this->GetTestModelString() << " tag: "
<< this->GetCurrentTag() << std::endl,
command->ShouldBeQuiet());
return true;
}
bool cmCTest::UpdateCTestConfiguration()
{
if (this->Impl->SuppressUpdatingCTestConfiguration) {

View File

@@ -70,9 +70,12 @@ public:
int Run(std::vector<std::string> const& args);
/**
* Initialize and finalize testing
* 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 InitializeFromCommand(cmCTestStartCommand* command);
int Initialize(const std::string& binary_dir, cmCTestStartCommand* command);
/**
* Process the dashboard client steps.
@@ -445,16 +448,6 @@ private:
void BlockTestErrorDiagnostics();
/**
* 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. Note that a declarative dashboard script does not actually
* call this method because it sets CTEST_COMMAND to drive a build
* through the ctest command line.
*/
int Initialize(const std::string& binary_dir, cmCTestStartCommand* command);
/** parse the option after -D and convert it into the appropriate steps */
bool AddTestsForDashboardType(std::string const& targ);