cmCTestTestHandler.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. /*
  54. * Set tests properties
  55. */
  56. bool SetTestsProperties(const std::vector<std::string>& args);
  57. struct cmCTestTestResult
  58. {
  59. std::string m_Name;
  60. std::string m_Path;
  61. std::string m_FullCommandLine;
  62. double m_ExecutionTime;
  63. int m_ReturnValue;
  64. int m_Status;
  65. std::string m_CompletionStatus;
  66. std::string m_Output;
  67. std::string m_RegressionImages;
  68. int m_TestCount;
  69. };
  70. void Initialize();
  71. protected:
  72. struct cmCTestTestProperties
  73. {
  74. cmStdString m_Name;
  75. cmStdString m_Directory;
  76. std::vector<std::string> m_Args;
  77. bool m_IsInBasedOnREOptions;
  78. bool m_WillFail;
  79. };
  80. virtual int PreProcessHandler();
  81. virtual int PostProcessHandler();
  82. virtual void GenerateTestCommand(std::vector<const char*>& args);
  83. int ExecuteCommands(std::vector<cmStdString>& vec);
  84. double m_ElapsedTestingTime;
  85. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  86. tm_TestResultsVector m_TestResults;
  87. std::vector<cmStdString> m_CustomTestsIgnore;
  88. std::string m_StartTest;
  89. std::string m_EndTest;
  90. bool m_MemCheck;
  91. private:
  92. enum { // Program statuses
  93. NOT_RUN = 0,
  94. TIMEOUT,
  95. SEGFAULT,
  96. ILLEGAL,
  97. INTERRUPT,
  98. NUMERICAL,
  99. OTHER_FAULT,
  100. FAILED,
  101. BAD_COMMAND,
  102. COMPLETED
  103. };
  104. /**
  105. * Generate the Dart compatible output
  106. */
  107. virtual void GenerateDartOutput(std::ostream& os);
  108. /**
  109. * Run the test for a directory and any subdirectories
  110. */
  111. void ProcessDirectory(std::vector<cmStdString> &passed,
  112. std::vector<cmStdString> &failed);
  113. typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
  114. /**
  115. * Get the list of tests in directory and subdirectories.
  116. */
  117. void GetListOfTests();
  118. /**
  119. * Find the executable for a test
  120. */
  121. std::string FindTheExecutable(const char *exe);
  122. const char* GetTestStatus(int status);
  123. void ExpandTestsToRunInformation(int numPossibleTests);
  124. std::vector<cmStdString> m_CustomPreTest;
  125. std::vector<cmStdString> m_CustomPostTest;
  126. int m_CustomMaximumPassedTestOutputSize;
  127. int m_CustomMaximumFailedTestOutputSize;
  128. std::vector<int> m_TestsToRun;
  129. bool m_UseIncludeRegExp;
  130. bool m_UseExcludeRegExp;
  131. bool m_UseExcludeRegExpFirst;
  132. std::string m_IncludeRegExp;
  133. std::string m_ExcludeRegExp;
  134. cmsys::RegularExpression m_IncludeTestsRegularExpression;
  135. cmsys::RegularExpression m_ExcludeTestsRegularExpression;
  136. std::string GenerateRegressionImages(const std::string& xml);
  137. //! Clean test output to specified length
  138. bool CleanTestOutput(std::string& output, size_t length);
  139. std::string TestsToRunString;
  140. bool m_UseUnion;
  141. tm_ListOfTests m_TestList;
  142. cmsys::RegularExpression m_DartStuff;
  143. std::ostream* m_LogFile;
  144. };
  145. #endif