cmCTestTestHandler.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. /**
  26. * The main entry point for this class
  27. */
  28. int ProcessHandler();
  29. /**
  30. * When both -R and -I are used should te resulting test list be the
  31. * intersection or the union of the lists. By default it is the
  32. * intersection.
  33. */
  34. void SetUseUnion(bool val) { m_UseUnion = val; }
  35. /**
  36. * This method is called when reading CTest custom file
  37. */
  38. void PopulateCustomVectors(cmMakefile *mf);
  39. ///! Control the use of the regular expresisons, call these methods to turn
  40. ///them on
  41. void UseIncludeRegExp();
  42. void UseExcludeRegExp();
  43. void SetIncludeRegExp(const char *);
  44. void SetExcludeRegExp(const char *);
  45. ///! pass the -I argument down
  46. void SetTestsToRunInformation(const char*);
  47. cmCTestTestHandler();
  48. /*
  49. * Add the test to the list of tests to be executed
  50. */
  51. bool AddTest(const std::vector<std::string>& args);
  52. struct cmCTestTestResult
  53. {
  54. std::string m_Name;
  55. std::string m_Path;
  56. std::string m_FullCommandLine;
  57. double m_ExecutionTime;
  58. int m_ReturnValue;
  59. int m_Status;
  60. std::string m_CompletionStatus;
  61. std::string m_Output;
  62. std::string m_RegressionImages;
  63. int m_TestCount;
  64. };
  65. protected:
  66. struct cmCTestTestProperties
  67. {
  68. cmStdString m_Name;
  69. cmStdString m_Directory;
  70. std::vector<std::string> m_Args;
  71. bool m_IsInBasedOnREOptions;
  72. };
  73. virtual int PreProcessHandler();
  74. virtual int PostProcessHandler();
  75. virtual void GenerateTestCommand(std::vector<const char*>& args);
  76. int ExecuteCommands(std::vector<cmStdString>& vec);
  77. double m_ElapsedTestingTime;
  78. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  79. tm_TestResultsVector m_TestResults;
  80. std::vector<cmStdString> m_CustomTestsIgnore;
  81. std::string m_StartTest;
  82. std::string m_EndTest;
  83. bool m_MemCheck;
  84. private:
  85. enum { // Program statuses
  86. NOT_RUN = 0,
  87. TIMEOUT,
  88. SEGFAULT,
  89. ILLEGAL,
  90. INTERRUPT,
  91. NUMERICAL,
  92. OTHER_FAULT,
  93. FAILED,
  94. BAD_COMMAND,
  95. COMPLETED
  96. };
  97. /**
  98. * Generate the Dart compatible output
  99. */
  100. virtual void GenerateDartOutput(std::ostream& os);
  101. /**
  102. * Run the test for a directory and any subdirectories
  103. */
  104. void ProcessDirectory(std::vector<cmStdString> &passed,
  105. std::vector<cmStdString> &failed);
  106. typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
  107. /**
  108. * Get the list of tests in directory and subdirectories.
  109. */
  110. void GetListOfTests();
  111. /**
  112. * Find the executable for a test
  113. */
  114. std::string FindTheExecutable(const char *exe);
  115. const char* GetTestStatus(int status);
  116. void ExpandTestsToRunInformation(int numPossibleTests);
  117. std::vector<cmStdString> m_CustomPreTest;
  118. std::vector<cmStdString> m_CustomPostTest;
  119. int m_CustomMaximumPassedTestOutputSize;
  120. int m_CustomMaximumFailedTestOutputSize;
  121. std::vector<int> m_TestsToRun;
  122. bool m_UseIncludeRegExp;
  123. bool m_UseExcludeRegExp;
  124. bool m_UseExcludeRegExpFirst;
  125. std::string m_IncludeRegExp;
  126. std::string m_ExcludeRegExp;
  127. cmsys::RegularExpression m_IncludeTestsRegularExpression;
  128. cmsys::RegularExpression m_ExcludeTestsRegularExpression;
  129. std::string GenerateRegressionImages(const std::string& xml);
  130. //! Clean test output to specified length
  131. bool CleanTestOutput(std::string& output, size_t length);
  132. std::string TestsToRunString;
  133. bool m_UseUnion;
  134. tm_ListOfTests m_TestList;
  135. };
  136. #endif