ENH: Teach ctest_* to create appending XML files

This adds an APPEND option to the ctest_* commands which tells them to
put the Append="true" attribute in the Site element of their XML file.
This commit is contained in:
Brad King 2009-01-12 09:11:29 -05:00
parent ae2c4143d2
commit cccac773ce
11 changed files with 27 additions and 9 deletions

View File

@ -484,7 +484,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
std::vector<cmCTestBuildErrorWarning> ew, std::vector<cmCTestBuildErrorWarning> ew,
double elapsed_build_time) double elapsed_build_time)
{ {
this->CTest->StartXML(os); this->CTest->StartXML(os, this->AppendXML);
os << "<Build>\n" os << "<Build>\n"
<< "\t<StartDateTime>" << this->StartBuild << "</StartDateTime>\n" << "\t<StartDateTime>" << this->StartBuild << "</StartDateTime>\n"
<< "\t<StartBuildTime>" << << "\t<StartBuildTime>" <<

View File

@ -92,7 +92,7 @@ int cmCTestConfigureHandler::ProcessHandler()
if ( os ) if ( os )
{ {
this->CTest->StartXML(os); this->CTest->StartXML(os, this->AppendXML);
os << "<Configure>\n" os << "<Configure>\n"
<< "\t<StartDateTime>" << start_time << "</StartDateTime>" << "\t<StartDateTime>" << start_time << "</StartDateTime>"
<< std::endl << std::endl

View File

@ -169,7 +169,7 @@ bool cmCTestCoverageHandler::StartCoverageLogFile(
return false; return false;
} }
std::string local_start_time = this->CTest->CurrentTime(); std::string local_start_time = this->CTest->CurrentTime();
this->CTest->StartXML(covLogFile); this->CTest->StartXML(covLogFile, this->AppendXML);
covLogFile << "<CoverageLog>" << std::endl covLogFile << "<CoverageLog>" << std::endl
<< "\t<StartDateTime>" << local_start_time << "</StartDateTime>" << "\t<StartDateTime>" << local_start_time << "</StartDateTime>"
<< "\t<StartTime>" << "\t<StartTime>"
@ -388,7 +388,7 @@ int cmCTestCoverageHandler::ProcessHandler()
return -1; return -1;
} }
this->CTest->StartXML(covSumFile); this->CTest->StartXML(covSumFile, this->AppendXML);
// Produce output xml files // Produce output xml files
covSumFile << "<Coverage>" << std::endl covSumFile << "<Coverage>" << std::endl
@ -1440,7 +1440,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
"Cannot open coverage summary file." << std::endl); "Cannot open coverage summary file." << std::endl);
return 0; return 0;
} }
this->CTest->StartXML(covSumFile); this->CTest->StartXML(covSumFile, this->AppendXML);
double elapsed_time_start = cmSystemTools::GetTime(); double elapsed_time_start = cmSystemTools::GetTime();
std::string coverage_start_time = this->CTest->CurrentTime(); std::string coverage_start_time = this->CTest->CurrentTime();
covSumFile << "<Coverage>" << std::endl covSumFile << "<Coverage>" << std::endl

View File

@ -26,6 +26,7 @@ cmCTestGenericHandler::cmCTestGenericHandler()
this->HandlerVerbose = false; this->HandlerVerbose = false;
this->CTest = 0; this->CTest = 0;
this->SubmitIndex = 0; this->SubmitIndex = 0;
this->AppendXML = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -88,10 +88,13 @@ public:
void SetSubmitIndex(int idx) { this->SubmitIndex = idx; } void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
int GetSubmitIndex() { return this->SubmitIndex; } int GetSubmitIndex() { return this->SubmitIndex; }
void SetAppendXML(bool b) { this->AppendXML = b; }
protected: protected:
bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs); bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs);
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
bool AppendXML;
bool HandlerVerbose; bool HandlerVerbose;
cmCTest *CTest; cmCTest *CTest;
t_StringToString Options; t_StringToString Options;

View File

@ -33,6 +33,7 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
this->Arguments[ct_BUILD] = "BUILD"; this->Arguments[ct_BUILD] = "BUILD";
this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX"; this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX";
this->Last = ct_LAST; this->Last = ct_LAST;
this->AppendXML = false;
} }
bool cmCTestHandlerCommand bool cmCTestHandlerCommand
@ -73,6 +74,8 @@ bool cmCTestHandlerCommand
return false; return false;
} }
handler->SetAppendXML(this->AppendXML);
handler->PopulateCustomVectors(this->Makefile); handler->PopulateCustomVectors(this->Makefile);
if ( this->Values[ct_BUILD] ) if ( this->Values[ct_BUILD] )
{ {
@ -143,6 +146,14 @@ bool cmCTestHandlerCommand
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg) bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
{ {
// Look for non-value arguments common to all commands.
if(arg == "APPEND")
{
this->ArgumentDoing = ArgumentDoingNone;
this->AppendXML = true;
return true;
}
// Check for a keyword in our argument/value table. // Check for a keyword in our argument/value table.
for(unsigned int k=0; k < this->Arguments.size(); ++k) for(unsigned int k=0; k < this->Arguments.size(); ++k)
{ {

View File

@ -66,6 +66,8 @@ protected:
int ArgumentDoing; int ArgumentDoing;
unsigned int ArgumentIndex; unsigned int ArgumentIndex;
bool AppendXML;
std::string ReturnVariable; std::string ReturnVariable;
std::vector<const char*> Arguments; std::vector<const char*> Arguments;
std::vector<const char*> Values; std::vector<const char*> Values;

View File

@ -287,7 +287,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
return; return;
} }
this->CTest->StartXML(os); this->CTest->StartXML(os, this->AppendXML);
os << "<DynamicAnalysis Checker=\""; os << "<DynamicAnalysis Checker=\"";
switch ( this->MemoryTesterStyle ) switch ( this->MemoryTesterStyle )
{ {

View File

@ -1442,7 +1442,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
return; return;
} }
this->CTest->StartXML(os); this->CTest->StartXML(os, this->AppendXML);
os << "<Testing>\n" os << "<Testing>\n"
<< "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n" << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
<< "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n" << "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"

View File

@ -1269,7 +1269,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTest::StartXML(std::ostream& ostr) void cmCTest::StartXML(std::ostream& ostr, bool append)
{ {
if(this->CurrentTag.empty()) if(this->CurrentTag.empty())
{ {
@ -1289,6 +1289,7 @@ void cmCTest::StartXML(std::ostream& ostr)
<< this->GetTestModelString() << "\"\n\tName=\"" << this->GetTestModelString() << "\"\n\tName=\""
<< this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest" << this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest"
<< cmVersion::GetCMakeVersion() << "\"\n" << cmVersion::GetCMakeVersion() << "\"\n"
<< (append? "\tAppend=\"true\"\n":"")
<< "\tOSName=\"" << info.GetOSName() << "\"\n" << "\tOSName=\"" << info.GetOSName() << "\"\n"
<< "\tHostname=\"" << info.GetHostname() << "\"\n" << "\tHostname=\"" << info.GetHostname() << "\"\n"
<< "\tOSRelease=\"" << info.GetOSRelease() << "\"\n" << "\tOSRelease=\"" << info.GetOSRelease() << "\"\n"

View File

@ -199,7 +199,7 @@ public:
int* retVal = 0, const char* dir = 0, double timeout = 0.0); int* retVal = 0, const char* dir = 0, double timeout = 0.0);
//! Start CTest XML output file //! Start CTest XML output file
void StartXML(std::ostream& ostr); void StartXML(std::ostream& ostr, bool append);
//! End CTest XML output file //! End CTest XML output file
void EndXML(std::ostream& ostr); void EndXML(std::ostream& ostr);