diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 1e3d20d6d1..eea2da3be0 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -2,17 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGenericHandler.h" -#include -#include - #include "cmCTest.h" -#include "cmSystemTools.h" cmCTestGenericHandler::cmCTestGenericHandler(cmCTest* ctest) : CTest(ctest) { this->SetVerbose(ctest->GetExtraVerbose()); - this->SetSubmitIndex(ctest->GetSubmitIndex()); } cmCTestGenericHandler::~cmCTestGenericHandler() = default; @@ -21,61 +16,11 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, char const* name, cmGeneratedFileStream& xofs) { - if (!name) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create resulting XML file without providing the name" - << std::endl); - return false; - } - std::ostringstream ostr; - ostr << name; - if (this->SubmitIndex > 0) { - ostr << "_" << this->SubmitIndex; - } - ostr << ".xml"; - if (this->CTest->GetCurrentTag().empty()) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Current Tag empty, this may mean NightlyStartTime / " - "CTEST_NIGHTLY_START_TIME was not set correctly. Or " - "maybe you forgot to call ctest_start() before calling " - "ctest_configure()." - << std::endl); - cmSystemTools::SetFatalErrorOccurred(); - return false; - } - if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(), - xofs, true)) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create resulting XML file: " << ostr.str() - << std::endl); - return false; - } - this->CTest->AddSubmitFile(part, ostr.str()); - return true; + return this->CTest->StartResultingXML(part, name, this->SubmitIndex, xofs); } bool cmCTestGenericHandler::StartLogFile(char const* name, cmGeneratedFileStream& xofs) { - if (!name) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create log file without providing the name" - << std::endl); - return false; - } - std::ostringstream ostr; - ostr << "Last" << name; - if (this->SubmitIndex > 0) { - ostr << "_" << this->SubmitIndex; - } - if (!this->CTest->GetCurrentTag().empty()) { - ostr << "_" << this->CTest->GetCurrentTag(); - } - ostr << ".log"; - if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create log file: " << ostr.str() << std::endl); - return false; - } - return true; + return this->CTest->StartLogFile(name, this->SubmitIndex, xofs); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index af5308596b..5a7c309e5e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3102,11 +3102,6 @@ bool cmCTest::GetExtraVerbose() const return this->Impl->ExtraVerbose; } -int cmCTest::GetSubmitIndex() const -{ - return this->Impl->SubmitIndex; -} - bool cmCTest::GetInteractiveDebugMode() const { return this->Impl->InteractiveDebugMode; @@ -3611,3 +3606,67 @@ bool cmCTest::CompressString(std::string& str) return true; } + +bool cmCTest::StartResultingXML(Part part, char const* name, int submitIndex, + cmGeneratedFileStream& xofs) +{ + if (!name) { + cmCTestLog( + this, ERROR_MESSAGE, + "Cannot create resulting XML file without providing the name\n"); + return false; + } + if (submitIndex == 0) { + submitIndex = this->Impl->SubmitIndex; + } + std::ostringstream ostr; + ostr << name; + if (submitIndex > 0) { + ostr << "_" << submitIndex; + } + ostr << ".xml"; + if (this->Impl->CurrentTag.empty()) { + cmCTestLog(this, ERROR_MESSAGE, + "Current Tag empty, this may mean NightlyStartTime / " + "CTEST_NIGHTLY_START_TIME was not set correctly. Or " + "maybe you forgot to call ctest_start() before calling " + "ctest_configure().\n"); + cmSystemTools::SetFatalErrorOccurred(); + return false; + } + if (!this->OpenOutputFile(this->Impl->CurrentTag, ostr.str(), xofs, true)) { + cmCTestLog(this, ERROR_MESSAGE, + "Cannot create resulting XML file: " << ostr.str() << '\n'); + return false; + } + this->AddSubmitFile(part, ostr.str()); + return true; +} + +bool cmCTest::StartLogFile(char const* name, int submitIndex, + cmGeneratedFileStream& xofs) +{ + if (!name) { + cmCTestLog(this, ERROR_MESSAGE, + "Cannot create log file without providing the name\n"); + return false; + } + if (submitIndex == 0) { + submitIndex = this->Impl->SubmitIndex; + } + std::ostringstream ostr; + ostr << "Last" << name; + if (submitIndex > 0) { + ostr << "_" << submitIndex; + } + if (!this->Impl->CurrentTag.empty()) { + ostr << "_" << this->Impl->CurrentTag; + } + ostr << ".log"; + if (!this->OpenOutputFile("Temporary", ostr.str(), xofs)) { + cmCTestLog(this, ERROR_MESSAGE, + "Cannot create log file: " << ostr.str() << '\n'); + return false; + } + return true; +} diff --git a/Source/cmCTest.h b/Source/cmCTest.h index b3083441eb..c6bfedef44 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -385,7 +385,11 @@ public: bool GetVerbose() const; bool GetExtraVerbose() const; - int GetSubmitIndex() const; + + bool StartResultingXML(Part part, char const* name, int submitIndex, + cmGeneratedFileStream& xofs); + bool StartLogFile(char const* name, int submitIndex, + cmGeneratedFileStream& xofs); void AddSiteProperties(cmXMLWriter& xml, cmake* cm);