cmCTestSubmitHandler.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <cstddef>
  6. #include <iosfwd>
  7. #include <set>
  8. #include <string>
  9. #include <vector>
  10. #include "cmCTest.h"
  11. #include "cmCTestGenericHandler.h"
  12. /** \class cmCTestSubmitHandler
  13. * \brief Helper class for CTest
  14. *
  15. * Submit testing results
  16. *
  17. */
  18. class cmCTestSubmitHandler : public cmCTestGenericHandler
  19. {
  20. public:
  21. using Superclass = cmCTestGenericHandler;
  22. cmCTestSubmitHandler();
  23. ~cmCTestSubmitHandler() override { this->LogFile = nullptr; }
  24. /*
  25. * The main entry point for this class
  26. */
  27. int ProcessHandler() override;
  28. void Initialize() override;
  29. //! Set all the submit arguments
  30. int ProcessCommandLineArguments(
  31. const std::string& currentArg, size_t& idx,
  32. const std::vector<std::string>& allArgs) override;
  33. /** Specify a set of parts (by name) to submit. */
  34. void SelectParts(std::set<cmCTest::Part> const& parts);
  35. /** Specify a set of files to submit. */
  36. void SelectFiles(std::set<std::string> const& files);
  37. // handle the cdash file upload protocol
  38. int HandleCDashUploadFile(std::string const& file, std::string const& type);
  39. void SetHttpHeaders(std::vector<std::string> const& v)
  40. {
  41. if (this->CommandLineHttpHeaders.empty()) {
  42. this->HttpHeaders = v;
  43. } else {
  44. this->HttpHeaders = this->CommandLineHttpHeaders;
  45. this->HttpHeaders.insert(this->HttpHeaders.end(), v.begin(), v.end());
  46. }
  47. }
  48. private:
  49. void SetLogFile(std::ostream* ost) { this->LogFile = ost; }
  50. /**
  51. * Submit file using various ways
  52. */
  53. bool SubmitUsingHTTP(const std::string& localprefix,
  54. const std::vector<std::string>& files,
  55. const std::string& remoteprefix,
  56. const std::string& url);
  57. using cmCTestSubmitHandlerVectorOfChar = std::vector<char>;
  58. void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk);
  59. std::string GetSubmitResultsPrefix();
  60. int GetSubmitInactivityTimeout();
  61. class ResponseParser;
  62. std::string HTTPProxy;
  63. int HTTPProxyType;
  64. std::string HTTPProxyAuth;
  65. std::ostream* LogFile;
  66. bool SubmitPart[cmCTest::PartCount];
  67. bool HasWarnings;
  68. bool HasErrors;
  69. std::set<std::string> Files;
  70. std::vector<std::string> CommandLineHttpHeaders;
  71. std::vector<std::string> HttpHeaders;
  72. };