Changed XML formatting of files attached to test so that each file is archived and marked up individually, in order to make things easier on the CDash side. Also switched to using the NamedMeasurement tag instead of a new tag.
This commit is contained in:
parent
93407682fe
commit
5bfe1a1962
|
@ -1255,46 +1255,37 @@ void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os,
|
||||||
<< "\t</Test>" << std::endl;
|
<< "\t</Test>" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
void cmCTestTestHandler::AttachFiles(std::ostream& os,
|
void cmCTestTestHandler::AttachFiles(std::ostream& os,
|
||||||
cmCTestTestResult* result)
|
cmCTestTestResult* result)
|
||||||
{
|
{
|
||||||
if(result->Properties->AttachedFiles.empty())
|
for(std::vector<std::string>::const_iterator file =
|
||||||
|
result->Properties->AttachedFiles.begin();
|
||||||
|
file != result->Properties->AttachedFiles.end(); ++file)
|
||||||
{
|
{
|
||||||
return;
|
std::string base64 = this->EncodeFile(*file);
|
||||||
}
|
std::string fname = cmSystemTools::GetFilenameName(*file);
|
||||||
|
os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" "
|
||||||
std::string base64 = this->EncodeFiles(result);
|
"compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">"
|
||||||
if(base64 == "")
|
"\n\t\t\t<Value>\n\t\t\t"
|
||||||
{
|
<< base64
|
||||||
return;
|
<< "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n";
|
||||||
}
|
}
|
||||||
os << "\t\t<AttachedFiles encoding=\"base64\" compression=\"tar/gzip\">\n"
|
|
||||||
<< base64 << "\n"
|
|
||||||
<< "\t\t</AttachedFiles>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::string cmCTestTestHandler::EncodeFiles(cmCTestTestResult* result)
|
std::string cmCTestTestHandler::EncodeFile(std::string file)
|
||||||
{
|
{
|
||||||
//create the temp tar file
|
std::string tarFile = file + "_temp.tar.gz";
|
||||||
std::string tarFile = result->Name + "_attached.tar.gz";
|
|
||||||
std::vector<cmStdString> files;
|
std::vector<cmStdString> files;
|
||||||
|
files.push_back(file);
|
||||||
for(std::vector<std::string>::iterator f =
|
|
||||||
result->Properties->AttachedFiles.begin();
|
|
||||||
f != result->Properties->AttachedFiles.end(); ++f)
|
|
||||||
{
|
|
||||||
const cmStdString fname = f->c_str();
|
|
||||||
files.push_back(fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
|
if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error creating tar while "
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error creating tar while "
|
||||||
"attaching files to the following test: " << result->Name << std::endl);
|
"attaching file: " << file << std::endl);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
long len = cmSystemTools::FileLength(tarFile.c_str());
|
long len = cmSystemTools::FileLength(tarFile.c_str());
|
||||||
std::ifstream ifs(tarFile.c_str(), std::ios::in
|
std::ifstream ifs(tarFile.c_str(), std::ios::in
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -147,7 +147,7 @@ protected:
|
||||||
// Write attached test files into the xml
|
// Write attached test files into the xml
|
||||||
void AttachFiles(std::ostream& os, cmCTestTestResult* result);
|
void AttachFiles(std::ostream& os, cmCTestTestResult* result);
|
||||||
// Helper function to encode attached test files
|
// Helper function to encode attached test files
|
||||||
std::string EncodeFiles(cmCTestTestResult* result);
|
std::string EncodeFile(std::string file);
|
||||||
|
|
||||||
//! 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);
|
||||||
|
|
Loading…
Reference in New Issue