cmCTest: Extract utility functions from cmCTestGenericHandler
This commit is contained in:
parent
8d4743b9e9
commit
509b2cca66
@ -2,17 +2,12 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmCTestGenericHandler.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user