summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestUploadCommand.cxx
blob: 91808212c47a0a40dd721d60fe382e5b7c3e8f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#include "cmCTestUploadCommand.h"

#include <set>
#include <sstream>
#include <vector>

#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestUploadHandler.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmSystemTools.h"
#include "cm_static_string_view.hxx"

void cmCTestUploadCommand::BindArguments()
{
  this->Bind("FILES"_s, this->Files);
  this->Bind("QUIET"_s, this->Quiet);
  this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError);
}

void cmCTestUploadCommand::CheckArguments(std::vector<std::string> const&)
{
  cmEraseIf(this->Files, [this](std::string const& arg) -> bool {
    if (!cmSystemTools::FileExists(arg)) {
      std::ostringstream e;
      e << "File \"" << arg << "\" does not exist. Cannot submit "
        << "a non-existent file.";
      this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
      return true;
    }
    return false;
  });
}

cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
{
  cmCTestUploadHandler* handler = this->CTest->GetUploadHandler();
  handler->Initialize();
  handler->SetFiles(
    std::set<std::string>(this->Files.begin(), this->Files.end()));
  handler->SetQuiet(this->Quiet);
  return handler;
}