cmCTestGenericHandler.h 2.7 KB

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