cmCTestGenericHandler.h 2.7 KB

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