cmCTestUploadCommand.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCTestUploadCommand.h"
  4. #include <sstream>
  5. #include <vector>
  6. #include "cmCTest.h"
  7. #include "cmCTestGenericHandler.h"
  8. #include "cmCTestUploadHandler.h"
  9. #include "cmMakefile.h"
  10. #include "cmSystemTools.h"
  11. #include "cmake.h"
  12. cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
  13. {
  14. cmCTestGenericHandler* handler =
  15. this->CTest->GetInitializedHandler("upload");
  16. if (!handler) {
  17. this->SetError("internal CTest error. Cannot instantiate upload handler");
  18. return nullptr;
  19. }
  20. static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
  21. handler->SetQuiet(this->Quiet);
  22. return handler;
  23. }
  24. bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
  25. {
  26. if (arg == "FILES") {
  27. this->ArgumentDoing = ArgumentDoingFiles;
  28. return true;
  29. }
  30. if (arg == "QUIET") {
  31. this->ArgumentDoing = ArgumentDoingNone;
  32. this->Quiet = true;
  33. return true;
  34. }
  35. if (arg == "CAPTURE_CMAKE_ERROR") {
  36. this->ArgumentDoing = ArgumentDoingCaptureCMakeError;
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
  42. {
  43. if (this->ArgumentDoing == ArgumentDoingCaptureCMakeError) {
  44. this->Values[ct_CAPTURE_CMAKE_ERROR] = arg.c_str();
  45. return true;
  46. }
  47. if (this->ArgumentDoing == ArgumentDoingFiles) {
  48. if (cmSystemTools::FileExists(arg)) {
  49. this->Files.insert(arg);
  50. return true;
  51. }
  52. std::ostringstream e;
  53. e << "File \"" << arg << "\" does not exist. Cannot submit "
  54. << "a non-existent file.";
  55. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  56. this->ArgumentDoing = ArgumentDoingError;
  57. return false;
  58. }
  59. // Look for other arguments.
  60. return this->Superclass::CheckArgumentValue(arg);
  61. }