cmCTestGenericHandler.h 3.1 KB

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