cmCTestUploadHandler: Move class into cmCTestUploadCommand.cxx
Place declaration and definitions into places where following refactoring will cause minimal deltas.
This commit is contained in:
parent
1b8f9274b2
commit
db3ccdce41
@ -1114,7 +1114,6 @@ add_library(
|
||||
CTest/cmCTestUpdateCommand.cxx
|
||||
CTest/cmCTestUpdateHandler.cxx
|
||||
CTest/cmCTestUploadCommand.cxx
|
||||
CTest/cmCTestUploadHandler.cxx
|
||||
|
||||
CTest/cmCTestVC.cxx
|
||||
CTest/cmCTestVC.h
|
||||
|
@ -2,8 +2,10 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmCTestUploadCommand.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
@ -11,12 +13,34 @@
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmArgumentParser.h"
|
||||
#include "cmCTest.h"
|
||||
#include "cmCTestGenericHandler.h"
|
||||
#include "cmCTestUploadHandler.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmXMLWriter.h"
|
||||
|
||||
class cmCTestUploadHandler : public cmCTestGenericHandler
|
||||
{
|
||||
public:
|
||||
using Superclass = cmCTestGenericHandler;
|
||||
|
||||
cmCTestUploadHandler(cmCTest* ctest);
|
||||
|
||||
/*
|
||||
* The main entry point for this class
|
||||
*/
|
||||
int ProcessHandler() override;
|
||||
|
||||
/** Specify a set of files to submit. */
|
||||
void SetFiles(std::set<std::string> const& files);
|
||||
|
||||
private:
|
||||
std::set<std::string> Files;
|
||||
};
|
||||
|
||||
void cmCTestUploadCommand::CheckArguments(HandlerArguments& arguments,
|
||||
cmExecutionStatus& status) const
|
||||
@ -46,6 +70,63 @@ std::unique_ptr<cmCTestGenericHandler> cmCTestUploadCommand::InitializeHandler(
|
||||
return std::unique_ptr<cmCTestGenericHandler>(std::move(handler));
|
||||
}
|
||||
|
||||
cmCTestUploadHandler::cmCTestUploadHandler(cmCTest* ctest)
|
||||
: Superclass(ctest)
|
||||
{
|
||||
}
|
||||
|
||||
void cmCTestUploadHandler::SetFiles(std::set<std::string> const& files)
|
||||
{
|
||||
this->Files = files;
|
||||
}
|
||||
|
||||
int cmCTestUploadHandler::ProcessHandler()
|
||||
{
|
||||
cmGeneratedFileStream ofs;
|
||||
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
|
||||
ofs)) {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Cannot open Upload.xml file" << std::endl);
|
||||
return -1;
|
||||
}
|
||||
std::string buildname =
|
||||
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
|
||||
|
||||
cmXMLWriter xml(ofs);
|
||||
xml.StartDocument();
|
||||
xml.ProcessingInstruction("xml-stylesheet",
|
||||
"type=\"text/xsl\" "
|
||||
"href=\"Dart/Source/Server/XSL/Build.xsl "
|
||||
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
|
||||
xml.StartElement("Site");
|
||||
xml.Attribute("BuildName", buildname);
|
||||
xml.Attribute("BuildStamp",
|
||||
this->CTest->GetCurrentTag() + "-" +
|
||||
this->CTest->GetTestGroupString());
|
||||
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
|
||||
xml.Attribute("Generator",
|
||||
std::string("ctest-") + cmVersion::GetCMakeVersion());
|
||||
this->CTest->AddSiteProperties(xml, this->CMake);
|
||||
xml.StartElement("Upload");
|
||||
xml.Element("Time", std::chrono::system_clock::now());
|
||||
|
||||
for (std::string const& file : this->Files) {
|
||||
cmCTestOptionalLog(this->CTest, OUTPUT,
|
||||
"\tUpload file: " << file << std::endl, this->Quiet);
|
||||
xml.StartElement("File");
|
||||
xml.Attribute("filename", file);
|
||||
xml.StartElement("Content");
|
||||
xml.Attribute("encoding", "base64");
|
||||
xml.Content(this->CTest->Base64EncodeFile(file));
|
||||
xml.EndElement(); // Content
|
||||
xml.EndElement(); // File
|
||||
}
|
||||
xml.EndElement(); // Upload
|
||||
xml.EndElement(); // Site
|
||||
xml.EndDocument();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cmCTestUploadCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status) const
|
||||
{
|
||||
|
@ -1,69 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmCTestUploadHandler.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "cmCTest.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmXMLWriter.h"
|
||||
|
||||
cmCTestUploadHandler::cmCTestUploadHandler(cmCTest* ctest)
|
||||
: Superclass(ctest)
|
||||
{
|
||||
}
|
||||
|
||||
void cmCTestUploadHandler::SetFiles(std::set<std::string> const& files)
|
||||
{
|
||||
this->Files = files;
|
||||
}
|
||||
|
||||
int cmCTestUploadHandler::ProcessHandler()
|
||||
{
|
||||
cmGeneratedFileStream ofs;
|
||||
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
|
||||
ofs)) {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Cannot open Upload.xml file" << std::endl);
|
||||
return -1;
|
||||
}
|
||||
std::string buildname =
|
||||
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
|
||||
|
||||
cmXMLWriter xml(ofs);
|
||||
xml.StartDocument();
|
||||
xml.ProcessingInstruction("xml-stylesheet",
|
||||
"type=\"text/xsl\" "
|
||||
"href=\"Dart/Source/Server/XSL/Build.xsl "
|
||||
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
|
||||
xml.StartElement("Site");
|
||||
xml.Attribute("BuildName", buildname);
|
||||
xml.Attribute("BuildStamp",
|
||||
this->CTest->GetCurrentTag() + "-" +
|
||||
this->CTest->GetTestGroupString());
|
||||
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
|
||||
xml.Attribute("Generator",
|
||||
std::string("ctest-") + cmVersion::GetCMakeVersion());
|
||||
this->CTest->AddSiteProperties(xml, this->CMake);
|
||||
xml.StartElement("Upload");
|
||||
xml.Element("Time", std::chrono::system_clock::now());
|
||||
|
||||
for (std::string const& file : this->Files) {
|
||||
cmCTestOptionalLog(this->CTest, OUTPUT,
|
||||
"\tUpload file: " << file << std::endl, this->Quiet);
|
||||
xml.StartElement("File");
|
||||
xml.Attribute("filename", file);
|
||||
xml.StartElement("Content");
|
||||
xml.Attribute("encoding", "base64");
|
||||
xml.Content(this->CTest->Base64EncodeFile(file));
|
||||
xml.EndElement(); // Content
|
||||
xml.EndElement(); // File
|
||||
}
|
||||
xml.EndElement(); // Upload
|
||||
xml.EndElement(); // Site
|
||||
xml.EndDocument();
|
||||
return 0;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "cmCTestGenericHandler.h"
|
||||
|
||||
class cmCTest;
|
||||
|
||||
/** \class cmCTestUploadHandler
|
||||
* \brief Helper class for CTest
|
||||
*
|
||||
* Submit arbitrary files
|
||||
*
|
||||
*/
|
||||
class cmCTestUploadHandler : public cmCTestGenericHandler
|
||||
{
|
||||
public:
|
||||
using Superclass = cmCTestGenericHandler;
|
||||
|
||||
cmCTestUploadHandler(cmCTest* ctest);
|
||||
|
||||
/*
|
||||
* The main entry point for this class
|
||||
*/
|
||||
int ProcessHandler() override;
|
||||
|
||||
/** Specify a set of files to submit. */
|
||||
void SetFiles(std::set<std::string> const& files);
|
||||
|
||||
private:
|
||||
std::set<std::string> Files;
|
||||
};
|
Loading…
Reference in New Issue
Block a user