From f54699d31d482be87bb366d89ef2a4410544e04b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2025 09:11:14 -0500 Subject: [PATCH 1/3] cmCTest: De-duplicate working directory code --- Source/cmCTest.cxx | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 75ddcc9503..0a77b3842c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -716,20 +716,6 @@ int cmCTest::ProcessSteps() this->Impl->Verbose = true; this->Impl->ProduceXML = true; - std::string const currDir = cmSystemTools::GetLogicalWorkingDirectory(); - std::string workDir = currDir; - if (!this->Impl->TestDir.empty()) { - workDir = cmSystemTools::ToNormalizedPathOnDisk(this->Impl->TestDir); - } - - cmWorkingDirectory changeDir(workDir); - if (changeDir.Failed()) { - cmCTestLog(this, ERROR_MESSAGE, changeDir.GetError() << std::endl); - return 1; - } - - this->Impl->BinaryDir = workDir; - cmSystemTools::ConvertToUnixSlashes(this->Impl->BinaryDir); this->UpdateCTestConfiguration(); this->BlockTestErrorDiagnostics(); @@ -2648,6 +2634,19 @@ int cmCTest::Run(std::vector const& args) return this->RunScripts(runScripts); } + // Establish the working directory. + std::string const currDir = cmSystemTools::GetLogicalWorkingDirectory(); + std::string workDir = currDir; + if (!this->Impl->TestDir.empty()) { + workDir = cmSystemTools::ToNormalizedPathOnDisk(this->Impl->TestDir); + } + cmWorkingDirectory changeDir(workDir); + if (changeDir.Failed()) { + cmCTestLog(this, ERROR_MESSAGE, changeDir.GetError() << std::endl); + return 1; + } + this->Impl->BinaryDir = workDir; + // -D, -T, and/or -M was specified if (processSteps) { return this->ProcessSteps(); @@ -2682,18 +2681,6 @@ int cmCTest::ExecuteTests(std::vector const& args) this->Impl->ExtraVerbose = this->Impl->Verbose; this->Impl->Verbose = true; - std::string const currDir = cmSystemTools::GetLogicalWorkingDirectory(); - std::string workDir = currDir; - if (!this->Impl->TestDir.empty()) { - workDir = cmSystemTools::ToNormalizedPathOnDisk(this->Impl->TestDir); - } - - cmWorkingDirectory changeDir(workDir); - if (changeDir.Failed()) { - cmCTestLog(this, ERROR_MESSAGE, changeDir.GetError() << std::endl); - return 1; - } - cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); if (!this->Impl->InteractiveDebugMode) { this->BlockTestErrorDiagnostics(); @@ -2701,9 +2688,6 @@ int cmCTest::ExecuteTests(std::vector const& args) cmSystemTools::PutEnv("CTEST_INTERACTIVE_DEBUG_MODE=1"); } - this->Impl->BinaryDir = workDir; - cmSystemTools::ConvertToUnixSlashes(this->Impl->BinaryDir); - this->UpdateCTestConfiguration(); cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); From e47dc299679c57c9e8e43c1ac5c8fb08836ac566 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 6 Mar 2025 11:26:56 +0100 Subject: [PATCH 2/3] cmCTestStartCommand: Remove unnecessary code We called `UpdateCTestConfiguration` but set an internal option that made it a no-op. Instead, just do not call it. --- Source/CTest/cmCTestStartCommand.cxx | 2 -- Source/cmCTest.cxx | 10 ---------- Source/cmCTest.h | 6 ------ 3 files changed, 18 deletions(-) diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 0a4ef09268..e2b897e3ec 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -139,7 +139,6 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, return false; } - this->CTest->SetSuppressUpdatingCTestConfiguration(true); int model; if (smodel) { model = cmCTest::GetTestModelFromString(smodel); @@ -183,7 +182,6 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, &mf, "BuildName", "CTEST_BUILD_NAME", quiet); this->CTest->Initialize(bld_dir); - this->CTest->UpdateCTestConfiguration(); cmCTestOptionalLog( this->CTest, OUTPUT, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 0a77b3842c..eaa3eccda5 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -173,8 +173,6 @@ struct cmCTest::Private bool CompressXMLFiles = false; bool CompressTestOutput = true; - bool SuppressUpdatingCTestConfiguration = false; - bool Debug = false; bool Quiet = false; @@ -529,9 +527,6 @@ bool cmCTest::ReadExistingTag(bool quiet) bool cmCTest::UpdateCTestConfiguration() { - if (this->Impl->SuppressUpdatingCTestConfiguration) { - return true; - } std::string fileName = this->Impl->BinaryDir + "/CTestConfiguration.ini"; if (!cmSystemTools::FileExists(fileName)) { fileName = this->Impl->BinaryDir + "/DartConfiguration.tcl"; @@ -3171,11 +3166,6 @@ void cmCTest::ClearSubmitFiles(Part part) this->Impl->Parts[part].SubmitFiles.clear(); } -void cmCTest::SetSuppressUpdatingCTestConfiguration(bool val) -{ - this->Impl->SuppressUpdatingCTestConfiguration = val; -} - void cmCTest::AddCTestConfigurationOverwrite(std::string const& overStr) { size_t epos = overStr.find('='); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 339c7e2cfa..53e9b0eff4 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -298,12 +298,6 @@ public: /** Decode a URL to the original string. */ static std::string DecodeURL(std::string const&); - /** - * Should ctect configuration be updated. When using new style ctest - * script, this should be true. - */ - void SetSuppressUpdatingCTestConfiguration(bool val); - /** * Add overwrite to ctest configuration. * From 712cb8cb14b7e88d2618b63439d2393aa2076e28 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 6 Mar 2025 12:03:39 +0100 Subject: [PATCH 3/3] ctest: Restore support for -T Test without dashboard configuration Since commit 774fcbe49c (CTest: Base command line mode on top of scripting commands, 2024-10-05, v4.0.0-rc1~653^2) we drive dashboard client steps through `cmCTestHandlerCommand::ExecuteHandlerCommand` instead of calling `ProcessHandler` directly. This requires the `BuildDirectory` to be known to establish a work directory. Fixes: #26743 Co-authored-by: Brad King --- Source/cmCTest.cxx | 3 +++ .../CTestCommandLine/EmptyDirCoverage-ctest-result.txt | 1 - .../CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt | 2 +- Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-stderr.txt | 3 +++ Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake | 4 ++++ 5 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-result.txt create mode 100644 Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-stderr.txt diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index eaa3eccda5..8f691bf196 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -711,6 +711,9 @@ int cmCTest::ProcessSteps() this->Impl->Verbose = true; this->Impl->ProduceXML = true; + // Minimal dashboard client script configuration. + this->SetCTestConfiguration("BuildDirectory", this->Impl->BinaryDir); + this->UpdateCTestConfiguration(); this->BlockTestErrorDiagnostics(); diff --git a/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-result.txt b/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-result.txt deleted file mode 100644 index f5c89552bd..0000000000 --- a/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-result.txt +++ /dev/null @@ -1 +0,0 @@ -32 diff --git a/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt b/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt index f6d28a17f3..45230f79a6 100644 --- a/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt @@ -1,3 +1,3 @@ Cannot find file: [^ ]*/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-build/DartConfiguration.tcl -CTEST_BINARY_DIRECTORY not set + Cannot find any coverage files\. Ignoring Coverage request\.$ diff --git a/Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-stderr.txt b/Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-stderr.txt new file mode 100644 index 0000000000..d9c2ecbc13 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-stderr.txt @@ -0,0 +1,3 @@ +Cannot find file: [^ +]*/Tests/RunCMake/CTestCommandLine/EmptyDirTest-ctest-build/DartConfiguration.tcl +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 0786499318..31f3b72c05 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -554,6 +554,10 @@ set(ENV{CMAKE_TLS_VERIFY} 0) # Test fallback to env variable. run_FailDrop(TLSVerify-OFF-env) unset(ENV{CMAKE_TLS_VERIFY}) +run_cmake_command(EmptyDirTest-ctest + ${CMAKE_CTEST_COMMAND} -C Debug -M Experimental -T Test + ) + run_cmake_command(EmptyDirCoverage-ctest ${CMAKE_CTEST_COMMAND} -C Debug -M Experimental -T Coverage )