2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2011-02-18 20:11:51 +03:00
|
|
|
#include "cmCTestUploadHandler.h"
|
|
|
|
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmVersion.h"
|
2015-05-24 00:31:20 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2011-02-18 20:11:51 +03:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <ostream>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
|
2011-02-18 20:11:51 +03:00
|
|
|
cmCTestUploadHandler::cmCTestUploadHandler()
|
|
|
|
{
|
|
|
|
this->Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestUploadHandler::Initialize()
|
|
|
|
{
|
|
|
|
this->Superclass::Initialize();
|
|
|
|
this->Files.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files)
|
|
|
|
{
|
|
|
|
this->Files = files;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestUploadHandler::ProcessHandler()
|
|
|
|
{
|
|
|
|
cmGeneratedFileStream ofs;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
|
|
|
|
ofs)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open Upload.xml file"
|
|
|
|
<< std::endl);
|
2011-02-18 20:11:51 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string buildname =
|
|
|
|
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
|
2011-02-18 20:11:51 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator it;
|
2015-05-24 00:31:20 +03:00
|
|
|
|
|
|
|
cmXMLWriter xml(ofs);
|
|
|
|
xml.StartDocument();
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.ProcessingInstruction("xml-stylesheet",
|
|
|
|
"type=\"text/xsl\" "
|
|
|
|
"href=\"Dart/Source/Server/XSL/Build.xsl "
|
|
|
|
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
|
2015-05-24 00:31:20 +03:00
|
|
|
xml.StartElement("Site");
|
|
|
|
xml.Attribute("BuildName", buildname);
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Attribute("BuildStamp", this->CTest->GetCurrentTag() + "-" +
|
|
|
|
this->CTest->GetTestModelString());
|
2015-05-24 00:31:20 +03:00
|
|
|
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
|
|
|
|
xml.Attribute("Generator",
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string("ctest") + cmVersion::GetCMakeVersion());
|
2015-05-24 00:31:20 +03:00
|
|
|
this->CTest->AddSiteProperties(xml);
|
|
|
|
xml.StartElement("Upload");
|
2011-02-18 20:11:51 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Files.begin(); it != this->Files.end(); it++) {
|
2015-02-18 17:15:29 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"\tUpload file: " << *it << std::endl, this->Quiet);
|
2015-05-24 00:31:20 +03:00
|
|
|
xml.StartElement("File");
|
|
|
|
xml.Attribute("filename", *it);
|
|
|
|
xml.StartElement("Content");
|
|
|
|
xml.Attribute("encoding", "base64");
|
|
|
|
xml.Content(this->CTest->Base64EncodeFile(*it));
|
|
|
|
xml.EndElement(); // Content
|
|
|
|
xml.EndElement(); // File
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 00:31:20 +03:00
|
|
|
xml.EndElement(); // Upload
|
|
|
|
xml.EndElement(); // Site
|
|
|
|
xml.EndDocument();
|
2011-02-18 20:11:51 +03:00
|
|
|
return 0;
|
|
|
|
}
|