cmCTestTestHandler.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCTestTestHandler_h
  14. #define cmCTestTestHandler_h
  15. #include "cmCTestGenericHandler.h"
  16. #include <cmsys/RegularExpression.hxx>
  17. class cmMakefile;
  18. /** \class cmCTestTestHandler
  19. * \brief A class that handles ctest -S invocations
  20. *
  21. */
  22. class cmCTestTestHandler : public cmCTestGenericHandler
  23. {
  24. public:
  25. cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
  26. /**
  27. * The main entry point for this class
  28. */
  29. int ProcessHandler();
  30. /**
  31. * When both -R and -I are used should te resulting test list be the
  32. * intersection or the union of the lists. By default it is the
  33. * intersection.
  34. */
  35. void SetUseUnion(bool val) { m_UseUnion = val; }
  36. /**
  37. * This method is called when reading CTest custom file
  38. */
  39. void PopulateCustomVectors(cmMakefile *mf);
  40. ///! Control the use of the regular expresisons, call these methods to turn
  41. ///them on
  42. void UseIncludeRegExp();
  43. void UseExcludeRegExp();
  44. void SetIncludeRegExp(const char *);
  45. void SetExcludeRegExp(const char *);
  46. ///! pass the -I argument down
  47. void SetTestsToRunInformation(const char*);
  48. cmCTestTestHandler();
  49. /*
  50. * Add the test to the list of tests to be executed
  51. */
  52. bool AddTest(const std::vector<std::string>& args);
  53. struct cmCTestTestResult
  54. {
  55. std::string m_Name;
  56. std::string m_Path;
  57. std::string m_FullCommandLine;
  58. double m_ExecutionTime;
  59. int m_ReturnValue;
  60. int m_Status;
  61. std::string m_CompletionStatus;
  62. std::string m_Output;
  63. std::string m_RegressionImages;
  64. int m_TestCount;
  65. };
  66. void Initialize();
  67. protected:
  68. struct cmCTestTestProperties
  69. {
  70. cmStdString m_Name;
  71. cmStdString m_Directory;
  72. std::vector<std::string> m_Args;
  73. bool m_IsInBasedOnREOptions;
  74. };
  75. virtual int PreProcessHandler();
  76. virtual int PostProcessHandler();
  77. virtual void GenerateTestCommand(std::vector<const char*>& args);
  78. int ExecuteCommands(std::vector<cmStdString>& vec);
  79. double m_ElapsedTestingTime;
  80. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  81. tm_TestResultsVector m_TestResults;
  82. std::vector<cmStdString> m_CustomTestsIgnore;
  83. std::string m_StartTest;
  84. std::string m_EndTest;
  85. bool m_MemCheck;
  86. private:
  87. enum { // Program statuses
  88. NOT_RUN = 0,
  89. TIMEOUT,
  90. SEGFAULT,
  91. ILLEGAL,
  92. INTERRUPT,
  93. NUMERICAL,
  94. OTHER_FAULT,
  95. FAILED,
  96. BAD_COMMAND,
  97. COMPLETED
  98. };
  99. /**
  100. * Generate the Dart compatible output
  101. */
  102. virtual void GenerateDartOutput(std::ostream& os);
  103. /**
  104. * Run the test for a directory and any subdirectories
  105. */
  106. void ProcessDirectory(std::vector<cmStdString> &passed,
  107. std::vector<cmStdString> &failed);
  108. typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
  109. /**
  110. * Get the list of tests in directory and subdirectories.
  111. */
  112. void GetListOfTests();
  113. /**
  114. * Find the executable for a test
  115. */
  116. std::string FindTheExecutable(const char *exe);
  117. const char* GetTestStatus(int status);
  118. void ExpandTestsToRunInformation(int numPossibleTests);
  119. std::vector<cmStdString> m_CustomPreTest;
  120. std::vector<cmStdString> m_CustomPostTest;
  121. int m_CustomMaximumPassedTestOutputSize;
  122. int m_CustomMaximumFailedTestOutputSize;
  123. std::vector<int> m_TestsToRun;
  124. bool m_UseIncludeRegExp;
  125. bool m_UseExcludeRegExp;
  126. bool m_UseExcludeRegExpFirst;
  127. std::string m_IncludeRegExp;
  128. std::string m_ExcludeRegExp;
  129. cmsys::RegularExpression m_IncludeTestsRegularExpression;
  130. cmsys::RegularExpression m_ExcludeTestsRegularExpression;
  131. std::string GenerateRegressionImages(const std::string& xml);
  132. //! Clean test output to specified length
  133. bool CleanTestOutput(std::string& output, size_t length);
  134. std::string TestsToRunString;
  135. bool m_UseUnion;
  136. tm_ListOfTests m_TestList;
  137. cmsys::RegularExpression m_DartStuff;
  138. };
  139. #endif