cmCTestGenericHandler.h 3.0 KB

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