mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-25 08:46:18 +00:00
cmCTest{Test,MemCheck}Handler: Port to cmXMLWriter
This commit is contained in:
committed by
Brad King
parent
8fbc509a48
commit
b04500a725
@@ -21,7 +21,7 @@
|
|||||||
#include <cmsys/Glob.hxx>
|
#include <cmsys/Glob.hxx>
|
||||||
#include <cmsys/FStream.hxx>
|
#include <cmsys/FStream.hxx>
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmXMLSafe.h"
|
#include "cmXMLWriter.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@@ -352,55 +352,52 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
|
||||||
{
|
{
|
||||||
if ( !this->CTest->GetProduceXML() )
|
if ( !this->CTest->GetProduceXML() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->CTest->StartXML(os, this->AppendXML);
|
this->CTest->StartXML(xml, this->AppendXML);
|
||||||
os << "<DynamicAnalysis Checker=\"";
|
xml.StartElement("DynamicAnalysis");
|
||||||
switch ( this->MemoryTesterStyle )
|
switch ( this->MemoryTesterStyle )
|
||||||
{
|
{
|
||||||
case cmCTestMemCheckHandler::VALGRIND:
|
case cmCTestMemCheckHandler::VALGRIND:
|
||||||
os << "Valgrind";
|
xml.Attribute("Checker", "Valgrind");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::PURIFY:
|
case cmCTestMemCheckHandler::PURIFY:
|
||||||
os << "Purify";
|
xml.Attribute("Checker", "Purify");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
|
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
|
||||||
os << "BoundsChecker";
|
xml.Attribute("Checker", "BoundsChecker");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
|
case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
|
||||||
os << "AddressSanitizer";
|
xml.Attribute("Checker", "AddressSanitizer");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::THREAD_SANITIZER:
|
case cmCTestMemCheckHandler::THREAD_SANITIZER:
|
||||||
os << "ThreadSanitizer";
|
xml.Attribute("Checker", "ThreadSanitizer");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::MEMORY_SANITIZER:
|
case cmCTestMemCheckHandler::MEMORY_SANITIZER:
|
||||||
os << "MemorySanitizer";
|
xml.Attribute("Checker", "MemorySanitizer");
|
||||||
break;
|
break;
|
||||||
case cmCTestMemCheckHandler::UB_SANITIZER:
|
case cmCTestMemCheckHandler::UB_SANITIZER:
|
||||||
os << "UndefinedBehaviorSanitizer";
|
xml.Attribute("Checker", "UndefinedBehaviorSanitizer");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
os << "Unknown";
|
xml.Attribute("Checker", "Unknown");
|
||||||
}
|
}
|
||||||
os << "\">" << std::endl;
|
|
||||||
|
|
||||||
os << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
|
xml.Element("StartDateTime", this->StartTest);
|
||||||
<< "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
|
xml.Element("StartTestTime", this->StartTestTime);
|
||||||
<< "\t<TestList>\n";
|
xml.StartElement("TestList");
|
||||||
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
|
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
|
||||||
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmCTestTestResult *result = &this->TestResults[cc];
|
cmCTestTestResult *result = &this->TestResults[cc];
|
||||||
std::string testPath = result->Path + "/" + result->Name;
|
std::string testPath = result->Path + "/" + result->Name;
|
||||||
os << "\t\t<Test>" << cmXMLSafe(
|
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
|
||||||
this->CTest->GetShortPathToFile(testPath.c_str()))
|
|
||||||
<< "</Test>" << std::endl;
|
|
||||||
}
|
}
|
||||||
os << "\t</TestList>\n";
|
xml.EndElement(); // TestList
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
"-- Processing memory checking output: ", this->Quiet);
|
"-- Processing memory checking output: ", this->Quiet);
|
||||||
size_t total = this->TestResults.size();
|
size_t total = this->TestResults.size();
|
||||||
@@ -419,37 +416,33 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
|||||||
}
|
}
|
||||||
this->CleanTestOutput(memcheckstr,
|
this->CleanTestOutput(memcheckstr,
|
||||||
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
|
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
|
||||||
this->WriteTestResultHeader(os, result);
|
this->WriteTestResultHeader(xml, result);
|
||||||
os << "\t\t<Results>" << std::endl;
|
xml.StartElement("Results");
|
||||||
for(std::vector<int>::size_type kk = 0;
|
for(std::vector<int>::size_type kk = 0;
|
||||||
kk < memcheckresults.size(); ++kk)
|
kk < memcheckresults.size(); ++kk)
|
||||||
{
|
{
|
||||||
if ( memcheckresults[kk] )
|
if ( memcheckresults[kk] )
|
||||||
{
|
{
|
||||||
os << "\t\t\t<Defect type=\"" << this->ResultStringsLong[kk]
|
xml.StartElement("Defect");
|
||||||
<< "\">"
|
xml.Attribute("type", this->ResultStringsLong[kk]);
|
||||||
<< memcheckresults[kk]
|
xml.Content(memcheckresults[kk]);
|
||||||
<< "</Defect>" << std::endl;
|
xml.EndElement(); // Defect
|
||||||
}
|
}
|
||||||
this->GlobalResults[kk] += memcheckresults[kk];
|
this->GlobalResults[kk] += memcheckresults[kk];
|
||||||
}
|
}
|
||||||
|
xml.EndElement(); // Results
|
||||||
|
|
||||||
std::string logTag;
|
xml.StartElement("Log");
|
||||||
if(this->CTest->ShouldCompressMemCheckOutput())
|
if(this->CTest->ShouldCompressMemCheckOutput())
|
||||||
{
|
{
|
||||||
this->CTest->CompressString(memcheckstr);
|
this->CTest->CompressString(memcheckstr);
|
||||||
logTag = "\t<Log compression=\"gzip\" encoding=\"base64\">\n";
|
xml.Attribute("compression", "gzip");
|
||||||
}
|
xml.Attribute("encoding", "base64");
|
||||||
else
|
|
||||||
{
|
|
||||||
logTag = "\t<Log>\n";
|
|
||||||
}
|
}
|
||||||
|
xml.Content(memcheckstr);
|
||||||
|
xml.EndElement(); // Log
|
||||||
|
|
||||||
os
|
this->WriteTestResultFooter(xml, result);
|
||||||
<< "\t\t</Results>\n"
|
|
||||||
<< logTag << cmXMLSafe(memcheckstr) << std::endl
|
|
||||||
<< "\t</Log>\n";
|
|
||||||
this->WriteTestResultFooter(os, result);
|
|
||||||
if ( current < cc )
|
if ( current < cc )
|
||||||
{
|
{
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
|
||||||
@@ -460,7 +453,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
|||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
|
||||||
<< std::endl, this->Quiet);
|
<< std::endl, this->Quiet);
|
||||||
os << "\t<DefectList>" << std::endl;
|
xml.StartElement("DefectList");
|
||||||
for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
|
for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
|
||||||
{
|
{
|
||||||
if ( this->GlobalResults[cc] )
|
if ( this->GlobalResults[cc] )
|
||||||
@@ -473,21 +466,20 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
|||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
this->ResultStringsLong[cc] << " - "
|
this->ResultStringsLong[cc] << " - "
|
||||||
<< this->GlobalResults[cc] << std::endl, this->Quiet);
|
<< this->GlobalResults[cc] << std::endl, this->Quiet);
|
||||||
os << "\t\t<Defect Type=\"" << this->ResultStringsLong[cc]
|
xml.StartElement("Defect");
|
||||||
<< "\"/>" << std::endl;
|
xml.Attribute("Type", this->ResultStringsLong[cc]);
|
||||||
|
xml.EndElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << "\t</DefectList>" << std::endl;
|
xml.EndElement(); // DefectList
|
||||||
|
|
||||||
os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>" << std::endl;
|
xml.Element("EndDateTime", this->EndTest);
|
||||||
os << "\t<EndTestTime>" << this->EndTestTime
|
xml.Element("EndTestTime", this->EndTestTime);
|
||||||
<< "</EndTestTime>" << std::endl;
|
xml.Element("ElapsedMinutes",
|
||||||
os << "<ElapsedMinutes>"
|
static_cast<int>(this->ElapsedTestingTime/6)/10.0);
|
||||||
<< static_cast<int>(this->ElapsedTestingTime/6)/10.0
|
|
||||||
<< "</ElapsedMinutes>\n";
|
|
||||||
|
|
||||||
os << "</DynamicAnalysis>" << std::endl;
|
xml.EndElement(); // DynamicAnalysis
|
||||||
this->CTest->EndXML(os);
|
this->CTest->EndXML(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
|
class cmXMLWriter;
|
||||||
|
|
||||||
/** \class cmCTestMemCheckHandler
|
/** \class cmCTestMemCheckHandler
|
||||||
* \brief A class that handles ctest -S invocations
|
* \brief A class that handles ctest -S invocations
|
||||||
@@ -119,7 +120,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Generate the Dart compatible output
|
* Generate the Dart compatible output
|
||||||
*/
|
*/
|
||||||
void GenerateDartOutput(std::ostream& os);
|
void GenerateDartOutput(cmXMLWriter& xml);
|
||||||
|
|
||||||
std::vector<std::string> CustomPreMemCheck;
|
std::vector<std::string> CustomPreMemCheck;
|
||||||
std::vector<std::string> CustomPostMemCheck;
|
std::vector<std::string> CustomPostMemCheck;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
#include "cmCommand.h"
|
#include "cmCommand.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmXMLSafe.h"
|
#include "cmXMLWriter.h"
|
||||||
#include "cm_utf8.h"
|
#include "cm_utf8.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -633,7 +633,8 @@ int cmCTestTestHandler::ProcessHandler()
|
|||||||
this->LogFile = 0;
|
this->LogFile = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
this->GenerateDartOutput(xmlfile);
|
cmXMLWriter xml(xmlfile);
|
||||||
|
this->GenerateDartOutput(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! this->PostProcessHandler() )
|
if ( ! this->PostProcessHandler() )
|
||||||
@@ -1142,54 +1143,53 @@ void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
|
||||||
{
|
{
|
||||||
if ( !this->CTest->GetProduceXML() )
|
if ( !this->CTest->GetProduceXML() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->CTest->StartXML(os, this->AppendXML);
|
this->CTest->StartXML(xml, this->AppendXML);
|
||||||
os << "<Testing>\n"
|
xml.StartElement("Testing");
|
||||||
<< "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
|
xml.Element("StartDateTime", this->StartTest);
|
||||||
<< "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
|
xml.Element("StartTestTime", this->StartTestTime);
|
||||||
<< "\t<TestList>\n";
|
xml.StartElement("TestList");
|
||||||
cmCTestTestHandler::TestResultsVector::size_type cc;
|
cmCTestTestHandler::TestResultsVector::size_type cc;
|
||||||
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmCTestTestResult *result = &this->TestResults[cc];
|
cmCTestTestResult *result = &this->TestResults[cc];
|
||||||
std::string testPath = result->Path + "/" + result->Name;
|
std::string testPath = result->Path + "/" + result->Name;
|
||||||
os << "\t\t<Test>" << cmXMLSafe(
|
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
|
||||||
this->CTest->GetShortPathToFile(testPath.c_str()))
|
|
||||||
<< "</Test>" << std::endl;
|
|
||||||
}
|
}
|
||||||
os << "\t</TestList>\n";
|
xml.EndElement(); // TestList
|
||||||
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmCTestTestResult *result = &this->TestResults[cc];
|
cmCTestTestResult *result = &this->TestResults[cc];
|
||||||
this->WriteTestResultHeader(os, result);
|
this->WriteTestResultHeader(xml, result);
|
||||||
os << "\t\t<Results>" << std::endl;
|
xml.StartElement("Results");
|
||||||
if ( result->Status != cmCTestTestHandler::NOT_RUN )
|
if ( result->Status != cmCTestTestHandler::NOT_RUN )
|
||||||
{
|
{
|
||||||
if ( result->Status != cmCTestTestHandler::COMPLETED ||
|
if ( result->Status != cmCTestTestHandler::COMPLETED ||
|
||||||
result->ReturnValue )
|
result->ReturnValue )
|
||||||
{
|
{
|
||||||
os << "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.StartElement("NamedMeasurement");
|
||||||
"name=\"Exit Code\"><Value>"
|
xml.Attribute("type", "text/string");
|
||||||
<< cmXMLSafe(this->GetTestStatus(result->Status))
|
xml.Attribute("name", "Exit Code");
|
||||||
<< "</Value>"
|
xml.Element("Value", this->GetTestStatus(result->Status));
|
||||||
"</NamedMeasurement>\n"
|
xml.EndElement(); // NamedMeasurement
|
||||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.StartElement("NamedMeasurement");
|
||||||
"name=\"Exit Value\"><Value>"
|
xml.Attribute("type", "text/string");
|
||||||
<< result->ReturnValue
|
xml.Attribute("name", "Exit Value");
|
||||||
<< "</Value></NamedMeasurement>"
|
xml.Element("Value", result->ReturnValue);
|
||||||
<< std::endl;
|
xml.EndElement(); // NamedMeasurement
|
||||||
}
|
}
|
||||||
this->GenerateRegressionImages(os, result->DartString);
|
this->GenerateRegressionImages(xml, result->DartString);
|
||||||
os << "\t\t\t<NamedMeasurement type=\"numeric/double\" "
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "name=\"Execution Time\"><Value>"
|
xml.Attribute("type", "numeric/double");
|
||||||
<< result->ExecutionTime
|
xml.Attribute("name", "Execution Time");
|
||||||
<< "</Value></NamedMeasurement>\n";
|
xml.Element("Value", result->ExecutionTime);
|
||||||
|
xml.EndElement(); // NamedMeasurement
|
||||||
if(!result->Reason.empty())
|
if(!result->Reason.empty())
|
||||||
{
|
{
|
||||||
const char* reasonType = "Pass Reason";
|
const char* reasonType = "Pass Reason";
|
||||||
@@ -1198,109 +1198,103 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
|||||||
{
|
{
|
||||||
reasonType = "Fail Reason";
|
reasonType = "Fail Reason";
|
||||||
}
|
}
|
||||||
os << "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "name=\"" << reasonType << "\"><Value>"
|
xml.Attribute("type", "text/string");
|
||||||
<< cmXMLSafe(result->Reason)
|
xml.Attribute("name", reasonType);
|
||||||
<< "</Value></NamedMeasurement>\n";
|
xml.Element("Value", result->Reason);
|
||||||
|
xml.EndElement(); // NamedMeasurement
|
||||||
}
|
}
|
||||||
os
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.Attribute("type", "text/string");
|
||||||
<< "name=\"Completion Status\"><Value>"
|
xml.Attribute("name", "Completion Status");
|
||||||
<< cmXMLSafe(result->CompletionStatus)
|
xml.Element("Value", result->CompletionStatus);
|
||||||
<< "</Value></NamedMeasurement>\n";
|
xml.EndElement(); // NamedMeasurement
|
||||||
}
|
}
|
||||||
os
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.Attribute("type", "text/string");
|
||||||
<< "name=\"Command Line\"><Value>"
|
xml.Attribute("name", "Command Line");
|
||||||
<< cmXMLSafe(result->FullCommandLine)
|
xml.Element("Value", result->FullCommandLine);
|
||||||
<< "</Value></NamedMeasurement>\n";
|
xml.EndElement(); // NamedMeasurement
|
||||||
std::map<std::string,std::string>::iterator measureIt;
|
std::map<std::string,std::string>::iterator measureIt;
|
||||||
for ( measureIt = result->Properties->Measurements.begin();
|
for ( measureIt = result->Properties->Measurements.begin();
|
||||||
measureIt != result->Properties->Measurements.end();
|
measureIt != result->Properties->Measurements.end();
|
||||||
++ measureIt )
|
++ measureIt )
|
||||||
{
|
{
|
||||||
os
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
xml.Attribute("type", "text/string");
|
||||||
<< "name=\"" << measureIt->first << "\"><Value>"
|
xml.Attribute("name", measureIt->first);
|
||||||
<< cmXMLSafe(measureIt->second)
|
xml.Element("Value", measureIt->second);
|
||||||
<< "</Value></NamedMeasurement>\n";
|
xml.EndElement(); // NamedMeasurement
|
||||||
}
|
}
|
||||||
os
|
xml.StartElement("Measurement");
|
||||||
<< "\t\t\t<Measurement>\n"
|
xml.StartElement("Value");
|
||||||
<< "\t\t\t\t<Value"
|
if (result->CompressOutput)
|
||||||
<< (result->CompressOutput ?
|
{
|
||||||
" encoding=\"base64\" compression=\"gzip\">"
|
xml.Attribute("encoding", "base64");
|
||||||
: ">");
|
xml.Attribute("compression", "gzip");
|
||||||
os << cmXMLSafe(result->Output);
|
}
|
||||||
os
|
xml.Content(result->Output);
|
||||||
<< "</Value>\n"
|
xml.EndElement(); // Value
|
||||||
<< "\t\t\t</Measurement>\n"
|
xml.EndElement(); // Measurement
|
||||||
<< "\t\t</Results>\n";
|
xml.EndElement(); // Results
|
||||||
|
|
||||||
this->AttachFiles(os, result);
|
this->AttachFiles(xml, result);
|
||||||
this->WriteTestResultFooter(os, result);
|
this->WriteTestResultFooter(xml, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>\n"
|
xml.Element("EndDateTime", this->EndTest);
|
||||||
<< "\t<EndTestTime>" << this->EndTestTime << "</EndTestTime>\n"
|
xml.Element("EndTestTime", this->EndTestTime);
|
||||||
<< "<ElapsedMinutes>"
|
xml.Element("ElapsedMinutes",
|
||||||
<< static_cast<int>(this->ElapsedTestingTime/6)/10.0
|
static_cast<int>(this->ElapsedTestingTime/6)/10.0);
|
||||||
<< "</ElapsedMinutes>"
|
xml.EndElement(); // Testing
|
||||||
<< "</Testing>" << std::endl;
|
this->CTest->EndXML(xml);
|
||||||
this->CTest->EndXML(os);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::WriteTestResultHeader(std::ostream& os,
|
void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
|
||||||
cmCTestTestResult* result)
|
cmCTestTestResult* result)
|
||||||
{
|
{
|
||||||
os << "\t<Test Status=\"";
|
xml.StartElement("Test");
|
||||||
if ( result->Status == cmCTestTestHandler::COMPLETED )
|
if ( result->Status == cmCTestTestHandler::COMPLETED )
|
||||||
{
|
{
|
||||||
os << "passed";
|
xml.Attribute("Status", "passed");
|
||||||
}
|
}
|
||||||
else if ( result->Status == cmCTestTestHandler::NOT_RUN )
|
else if ( result->Status == cmCTestTestHandler::NOT_RUN )
|
||||||
{
|
{
|
||||||
os << "notrun";
|
xml.Attribute("Status", "notrun");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << "failed";
|
xml.Attribute("Status", "failed");
|
||||||
}
|
}
|
||||||
std::string testPath = result->Path + "/" + result->Name;
|
std::string testPath = result->Path + "/" + result->Name;
|
||||||
os << "\">\n"
|
xml.Element("Name", result->Name);
|
||||||
<< "\t\t<Name>" << cmXMLSafe(result->Name) << "</Name>\n"
|
xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
|
||||||
<< "\t\t<Path>" << cmXMLSafe(
|
xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str()));
|
||||||
this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n"
|
xml.Element("FullCommandLine", result->FullCommandLine);
|
||||||
<< "\t\t<FullName>" << cmXMLSafe(
|
|
||||||
this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n"
|
|
||||||
<< "\t\t<FullCommandLine>"
|
|
||||||
<< cmXMLSafe(result->FullCommandLine)
|
|
||||||
<< "</FullCommandLine>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os,
|
void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
|
||||||
cmCTestTestResult* result)
|
cmCTestTestResult* result)
|
||||||
{
|
{
|
||||||
if(!result->Properties->Labels.empty())
|
if(!result->Properties->Labels.empty())
|
||||||
{
|
{
|
||||||
os << "\t\t<Labels>\n";
|
xml.StartElement("Labels");
|
||||||
std::vector<std::string> const& labels = result->Properties->Labels;
|
std::vector<std::string> const& labels = result->Properties->Labels;
|
||||||
for(std::vector<std::string>::const_iterator li = labels.begin();
|
for(std::vector<std::string>::const_iterator li = labels.begin();
|
||||||
li != labels.end(); ++li)
|
li != labels.end(); ++li)
|
||||||
{
|
{
|
||||||
os << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
|
xml.Element("Label", *li);
|
||||||
}
|
}
|
||||||
os << "\t\t</Labels>\n";
|
xml.EndElement(); // Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
os
|
xml.EndElement(); // Test
|
||||||
<< "\t</Test>" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::AttachFiles(std::ostream& os,
|
void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
|
||||||
cmCTestTestResult* result)
|
cmCTestTestResult* result)
|
||||||
{
|
{
|
||||||
if(result->Status != cmCTestTestHandler::COMPLETED
|
if(result->Status != cmCTestTestHandler::COMPLETED
|
||||||
@@ -1317,11 +1311,14 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os,
|
|||||||
{
|
{
|
||||||
const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
|
const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
|
||||||
std::string fname = cmSystemTools::GetFilenameName(*file);
|
std::string fname = cmSystemTools::GetFilenameName(*file);
|
||||||
os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" "
|
xml.StartElement("NamedMeasurement");
|
||||||
"compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">"
|
xml.Attribute("name", "Attached File");
|
||||||
"\n\t\t\t<Value>\n\t\t\t"
|
xml.Attribute("encoding", "base64");
|
||||||
<< base64
|
xml.Attribute("compression", "tar/gzip");
|
||||||
<< "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n";
|
xml.Attribute("filename", fname);
|
||||||
|
xml.Attribute("type", "file");
|
||||||
|
xml.Element("Value", base64);
|
||||||
|
xml.EndElement(); // NamedMeasurement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1829,7 +1826,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
|
|||||||
#define SPACE_REGEX "[ \t\r\n]"
|
#define SPACE_REGEX "[ \t\r\n]"
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::GenerateRegressionImages(
|
void cmCTestTestHandler::GenerateRegressionImages(
|
||||||
std::ostream& ostr, const std::string& xml)
|
cmXMLWriter& xml, const std::string& dart)
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression twoattributes(
|
cmsys::RegularExpression twoattributes(
|
||||||
"<DartMeasurement"
|
"<DartMeasurement"
|
||||||
@@ -1865,69 +1862,61 @@ void cmCTestTestHandler::GenerateRegressionImages(
|
|||||||
SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
|
SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
std::string cxml = xml;
|
std::string cxml = dart;
|
||||||
while ( ! done )
|
while ( ! done )
|
||||||
{
|
{
|
||||||
if ( twoattributes.find(cxml) )
|
if ( twoattributes.find(cxml) )
|
||||||
{
|
{
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(twoattributes.match(1).c_str(),
|
||||||
<< " " << twoattributes.match(1) << "=\""
|
twoattributes.match(2));
|
||||||
<< twoattributes.match(2) << "\""
|
xml.Attribute(twoattributes.match(3).c_str(),
|
||||||
<< " " << twoattributes.match(3) << "=\""
|
twoattributes.match(4));
|
||||||
<< twoattributes.match(4) << "\""
|
xml.Element("Value", twoattributes.match(5));
|
||||||
<< "><Value>" << twoattributes.match(5)
|
xml.EndElement();
|
||||||
<< "</Value></NamedMeasurement>"
|
|
||||||
<< std::endl;
|
|
||||||
cxml.erase(twoattributes.start(),
|
cxml.erase(twoattributes.start(),
|
||||||
twoattributes.end() - twoattributes.start());
|
twoattributes.end() - twoattributes.start());
|
||||||
}
|
}
|
||||||
else if ( threeattributes.find(cxml) )
|
else if ( threeattributes.find(cxml) )
|
||||||
{
|
{
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(threeattributes.match(1).c_str(),
|
||||||
<< " " << threeattributes.match(1) << "=\""
|
threeattributes.match(2));
|
||||||
<< threeattributes.match(2) << "\""
|
xml.Attribute(threeattributes.match(3).c_str(),
|
||||||
<< " " << threeattributes.match(3) << "=\""
|
threeattributes.match(4));
|
||||||
<< threeattributes.match(4) << "\""
|
xml.Attribute(threeattributes.match(5).c_str(),
|
||||||
<< " " << threeattributes.match(5) << "=\""
|
threeattributes.match(6));
|
||||||
<< threeattributes.match(6) << "\""
|
xml.Element("Value", twoattributes.match(7));
|
||||||
<< "><Value>" << threeattributes.match(7)
|
xml.EndElement();
|
||||||
<< "</Value></NamedMeasurement>"
|
|
||||||
<< std::endl;
|
|
||||||
cxml.erase(threeattributes.start(),
|
cxml.erase(threeattributes.start(),
|
||||||
threeattributes.end() - threeattributes.start());
|
threeattributes.end() - threeattributes.start());
|
||||||
}
|
}
|
||||||
else if ( fourattributes.find(cxml) )
|
else if ( fourattributes.find(cxml) )
|
||||||
{
|
{
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(fourattributes.match(1).c_str(),
|
||||||
<< " " << fourattributes.match(1) << "=\""
|
fourattributes.match(2));
|
||||||
<< fourattributes.match(2) << "\""
|
xml.Attribute(fourattributes.match(3).c_str(),
|
||||||
<< " " << fourattributes.match(3) << "=\""
|
fourattributes.match(4));
|
||||||
<< fourattributes.match(4) << "\""
|
xml.Attribute(fourattributes.match(5).c_str(),
|
||||||
<< " " << fourattributes.match(5) << "=\""
|
fourattributes.match(6));
|
||||||
<< fourattributes.match(6) << "\""
|
xml.Attribute(fourattributes.match(7).c_str(),
|
||||||
<< " " << fourattributes.match(7) << "=\""
|
fourattributes.match(8));
|
||||||
<< fourattributes.match(8) << "\""
|
xml.Element("Value", twoattributes.match(9));
|
||||||
<< "><Value>" << fourattributes.match(9)
|
xml.EndElement();
|
||||||
<< "</Value></NamedMeasurement>"
|
|
||||||
<< std::endl;
|
|
||||||
cxml.erase(fourattributes.start(),
|
cxml.erase(fourattributes.start(),
|
||||||
fourattributes.end() - fourattributes.start());
|
fourattributes.end() - fourattributes.start());
|
||||||
}
|
}
|
||||||
else if ( cdatastart.find(cxml) && cdataend.find(cxml) )
|
else if ( cdatastart.find(cxml) && cdataend.find(cxml) )
|
||||||
{
|
{
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(cdatastart.match(1).c_str(), cdatastart.match(2));
|
||||||
<< " " << cdatastart.match(1) << "=\""
|
xml.Attribute(cdatastart.match(3).c_str(), cdatastart.match(4));
|
||||||
<< cdatastart.match(2) << "\""
|
xml.StartElement("Value");
|
||||||
<< " " << cdatastart.match(3) << "=\""
|
xml.CData(
|
||||||
<< cdatastart.match(4) << "\""
|
cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
|
||||||
<< "><Value><![CDATA["
|
xml.EndElement(); // Value
|
||||||
<< cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end())
|
xml.EndElement(); // NamedMeasurement
|
||||||
<< "]]></Value></NamedMeasurement>"
|
|
||||||
<< std::endl;
|
|
||||||
cxml.erase(cdatastart.start(),
|
cxml.erase(cdatastart.start(),
|
||||||
cdataend.end() - cdatastart.start());
|
cdataend.end() - cdatastart.start());
|
||||||
}
|
}
|
||||||
@@ -1953,13 +1942,12 @@ void cmCTestTestHandler::GenerateRegressionImages(
|
|||||||
v2 = "text/string";
|
v2 = "text/string";
|
||||||
}
|
}
|
||||||
|
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(k1.c_str(), v1);
|
||||||
<< " " << k1 << "=\"" << v1 << "\""
|
xml.Attribute(k2.c_str(), v2);
|
||||||
<< " " << k2 << "=\"" << v2 << "\""
|
xml.Attribute("encoding", "none");
|
||||||
<< " encoding=\"none\""
|
xml.Element("Value", "Image " + filename + " is empty");
|
||||||
<< "><Value>Image " << filename
|
xml.EndElement();
|
||||||
<< " is empty</Value></NamedMeasurement>";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1977,14 +1965,13 @@ void cmCTestTestHandler::GenerateRegressionImages(
|
|||||||
size_t rlen
|
size_t rlen
|
||||||
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
|
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
|
||||||
|
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute(measurementfile.match(1).c_str(),
|
||||||
<< " " << measurementfile.match(1) << "=\""
|
measurementfile.match(2));
|
||||||
<< measurementfile.match(2) << "\""
|
xml.Attribute(measurementfile.match(3).c_str(),
|
||||||
<< " " << measurementfile.match(3) << "=\""
|
measurementfile.match(4));
|
||||||
<< measurementfile.match(4) << "\""
|
xml.Attribute("encoding", "base64");
|
||||||
<< " encoding=\"base64\""
|
std::stringstream ostr;
|
||||||
<< ">" << std::endl << "\t\t\t\t<Value>";
|
|
||||||
for (size_t cc = 0; cc < rlen; cc ++ )
|
for (size_t cc = 0; cc < rlen; cc ++ )
|
||||||
{
|
{
|
||||||
ostr << encoded_buffer[cc];
|
ostr << encoded_buffer[cc];
|
||||||
@@ -1993,9 +1980,8 @@ void cmCTestTestHandler::GenerateRegressionImages(
|
|||||||
ostr << std::endl;
|
ostr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ostr
|
xml.Element("Value", ostr.str());
|
||||||
<< "</Value>" << std::endl << "\t\t\t</NamedMeasurement>"
|
xml.EndElement(); // NamedMeasurement
|
||||||
<< std::endl;
|
|
||||||
delete [] file_buffer;
|
delete [] file_buffer;
|
||||||
delete [] encoded_buffer;
|
delete [] encoded_buffer;
|
||||||
}
|
}
|
||||||
@@ -2007,13 +1993,11 @@ void cmCTestTestHandler::GenerateRegressionImages(
|
|||||||
{
|
{
|
||||||
idx = 2;
|
idx = 2;
|
||||||
}
|
}
|
||||||
ostr
|
xml.StartElement("NamedMeasurement");
|
||||||
<< "\t\t\t<NamedMeasurement"
|
xml.Attribute("name", measurementfile.match(idx));
|
||||||
<< " name=\"" << measurementfile.match(idx) << "\""
|
xml.Attribute("text", "text/string");
|
||||||
<< " text=\"text/string\""
|
xml.Element("Value", "File " + filename + " not found");
|
||||||
<< "><Value>File " << filename
|
xml.EndElement();
|
||||||
<< " not found</Value></NamedMeasurement>"
|
|
||||||
<< std::endl;
|
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
|
||||||
<< "\" not found." << std::endl, this->Quiet);
|
<< "\" not found." << std::endl, this->Quiet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
|
class cmXMLWriter;
|
||||||
|
|
||||||
/** \class cmCTestTestHandler
|
/** \class cmCTestTestHandler
|
||||||
* \brief A class that handles ctest -S invocations
|
* \brief A class that handles ctest -S invocations
|
||||||
@@ -164,10 +165,10 @@ protected:
|
|||||||
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
|
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
|
||||||
int ExecuteCommands(std::vector<std::string>& vec);
|
int ExecuteCommands(std::vector<std::string>& vec);
|
||||||
|
|
||||||
void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result);
|
void WriteTestResultHeader(cmXMLWriter& xml, cmCTestTestResult* result);
|
||||||
void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result);
|
void WriteTestResultFooter(cmXMLWriter& xml, cmCTestTestResult* result);
|
||||||
// Write attached test files into the xml
|
// Write attached test files into the xml
|
||||||
void AttachFiles(std::ostream& os, cmCTestTestResult* result);
|
void AttachFiles(cmXMLWriter& xml, cmCTestTestResult* result);
|
||||||
|
|
||||||
//! Clean test output to specified length
|
//! Clean test output to specified length
|
||||||
bool CleanTestOutput(std::string& output, size_t length);
|
bool CleanTestOutput(std::string& output, size_t length);
|
||||||
@@ -204,7 +205,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Generate the Dart compatible output
|
* Generate the Dart compatible output
|
||||||
*/
|
*/
|
||||||
virtual void GenerateDartOutput(std::ostream& os);
|
virtual void GenerateDartOutput(cmXMLWriter& xml);
|
||||||
|
|
||||||
void PrintLabelSummary();
|
void PrintLabelSummary();
|
||||||
/**
|
/**
|
||||||
@@ -270,7 +271,7 @@ private:
|
|||||||
cmsys::RegularExpression IncludeTestsRegularExpression;
|
cmsys::RegularExpression IncludeTestsRegularExpression;
|
||||||
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
||||||
|
|
||||||
void GenerateRegressionImages(std::ostream& ostr, const std::string& xml);
|
void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
|
||||||
cmsys::RegularExpression DartStuff1;
|
cmsys::RegularExpression DartStuff1;
|
||||||
void CheckLabelFilter(cmCTestTestProperties& it);
|
void CheckLabelFilter(cmCTestTestProperties& it);
|
||||||
void CheckLabelFilterExclude(cmCTestTestProperties& it);
|
void CheckLabelFilterExclude(cmCTestTestProperties& it);
|
||||||
|
|||||||
Reference in New Issue
Block a user