cmCTestGenericHandler.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 <map>
  6. #include <string>
  7. #include <vector>
  8. #include <stddef.h>
  9. #include "cmCTest.h"
  10. #include "cmSystemTools.h"
  11. class cmCTestCommand;
  12. class cmGeneratedFileStream;
  13. class cmMakefile;
  14. /** \class cmCTestGenericHandler
  15. * \brief A superclass of all CTest Handlers
  16. *
  17. */
  18. class cmCTestGenericHandler
  19. {
  20. public:
  21. /**
  22. * If verbose then more information is printed out
  23. */
  24. void SetVerbose(bool val)
  25. {
  26. this->HandlerVerbose =
  27. val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
  28. }
  29. /**
  30. * Populate internals from CTest custom scripts
  31. */
  32. virtual void PopulateCustomVectors(cmMakefile*) {}
  33. /**
  34. * Do the actual processing. Subclass has to override it.
  35. * Return < 0 if error.
  36. */
  37. virtual int ProcessHandler() = 0;
  38. /**
  39. * Process command line arguments that are applicable for the handler
  40. */
  41. virtual int ProcessCommandLineArguments(
  42. const std::string& /*currentArg*/, size_t& /*idx*/,
  43. const std::vector<std::string>& /*allArgs*/)
  44. {
  45. return 1;
  46. }
  47. /**
  48. * Initialize handler
  49. */
  50. virtual void Initialize();
  51. /**
  52. * Set the CTest instance
  53. */
  54. void SetCTestInstance(cmCTest* ctest) { this->CTest = ctest; }
  55. cmCTest* GetCTestInstance() { return this->CTest; }
  56. /**
  57. * Construct handler
  58. */
  59. cmCTestGenericHandler();
  60. virtual ~cmCTestGenericHandler();
  61. using t_StringToString = std::map<std::string, std::string>;
  62. void SetPersistentOption(const std::string& op, const char* value);
  63. void SetOption(const std::string& op, const char* value);
  64. const char* GetOption(const std::string& op);
  65. void SetCommand(cmCTestCommand* command) { this->Command = command; }
  66. void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
  67. int GetSubmitIndex() { return this->SubmitIndex; }
  68. void SetAppendXML(bool b) { this->AppendXML = b; }
  69. void SetQuiet(bool b) { this->Quiet = b; }
  70. bool GetQuiet() { return this->Quiet; }
  71. void SetTestLoad(unsigned long load) { this->TestLoad = load; }
  72. unsigned long GetTestLoad() const { return this->TestLoad; }
  73. protected:
  74. bool StartResultingXML(cmCTest::Part part, const char* name,
  75. cmGeneratedFileStream& xofs);
  76. bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
  77. bool AppendXML;
  78. bool Quiet;
  79. unsigned long TestLoad;
  80. cmSystemTools::OutputOption HandlerVerbose;
  81. cmCTest* CTest;
  82. t_StringToString Options;
  83. t_StringToString PersistentOptions;
  84. cmCTestCommand* Command;
  85. int SubmitIndex;
  86. };