cmCTestGenericHandler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "cmCTest.h"
  8. #include "cmSystemTools.h"
  9. class cmGeneratedFileStream;
  10. class cmMakefile;
  11. class cmake;
  12. /** \class cmCTestGenericHandler
  13. * \brief A superclass of all CTest Handlers
  14. *
  15. */
  16. class cmCTestGenericHandler
  17. {
  18. public:
  19. /**
  20. * If verbose then more information is printed out
  21. */
  22. void SetVerbose(bool val)
  23. {
  24. this->HandlerVerbose =
  25. val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
  26. }
  27. /**
  28. * Populate internals from CTest custom scripts
  29. */
  30. virtual void PopulateCustomVectors(cmMakefile*) {}
  31. /**
  32. * Do the actual processing. Subclass has to override it.
  33. * Return < 0 if error.
  34. */
  35. virtual int ProcessHandler() = 0;
  36. /**
  37. * Get the CTest instance
  38. */
  39. cmCTest* GetCTestInstance() { return this->CTest; }
  40. /**
  41. * Construct handler
  42. */
  43. cmCTestGenericHandler(cmCTest* ctest);
  44. virtual ~cmCTestGenericHandler();
  45. using t_StringToString = std::map<std::string, std::string>;
  46. void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
  47. int GetSubmitIndex() { return this->SubmitIndex; }
  48. void SetAppendXML(bool b) { this->AppendXML = b; }
  49. void SetQuiet(bool b) { this->Quiet = b; }
  50. bool GetQuiet() { return this->Quiet; }
  51. void SetTestLoad(unsigned long load) { this->TestLoad = load; }
  52. unsigned long GetTestLoad() const { return this->TestLoad; }
  53. void SetCMakeInstance(cmake* cm) { this->CMake = cm; }
  54. protected:
  55. bool StartResultingXML(cmCTest::Part part, const char* name,
  56. cmGeneratedFileStream& xofs);
  57. bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
  58. bool AppendXML;
  59. bool Quiet;
  60. unsigned long TestLoad;
  61. cmSystemTools::OutputOption HandlerVerbose;
  62. cmCTest* CTest;
  63. t_StringToString LogFileNames;
  64. cmake* CMake = nullptr;
  65. int SubmitIndex;
  66. };