cmCTestTestHandler.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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) { this->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 Name;
  60. std::string Path;
  61. std::string FullCommandLine;
  62. double ExecutionTime;
  63. int ReturnValue;
  64. int Status;
  65. std::string CompletionStatus;
  66. std::string Output;
  67. std::string RegressionImages;
  68. int TestCount;
  69. };
  70. void Initialize();
  71. protected:
  72. struct cmCTestTestProperties
  73. {
  74. cmStdString Name;
  75. cmStdString Directory;
  76. std::vector<std::string> Args;
  77. std::vector<cmsys::RegularExpression> ErrorRegularExpressions;
  78. std::vector<cmsys::RegularExpression> RequiredRegularExpressions;
  79. bool IsInBasedOnREOptions;
  80. bool WillFail;
  81. };
  82. virtual int PreProcessHandler();
  83. virtual int PostProcessHandler();
  84. virtual void GenerateTestCommand(std::vector<const char*>& args);
  85. int ExecuteCommands(std::vector<cmStdString>& vec);
  86. //! Clean test output to specified length
  87. bool CleanTestOutput(std::string& output, size_t length);
  88. double ElapsedTestingTime;
  89. typedef std::vector<cmCTestTestResult> TestResultsVector;
  90. TestResultsVector TestResults;
  91. std::vector<cmStdString> CustomTestsIgnore;
  92. std::string StartTest;
  93. std::string EndTest;
  94. bool MemCheck;
  95. int CustomMaximumPassedTestOutputSize;
  96. int CustomMaximumFailedTestOutputSize;
  97. private:
  98. enum { // Program statuses
  99. NOT_RUN = 0,
  100. TIMEOUT,
  101. SEGFAULT,
  102. ILLEGAL,
  103. INTERRUPT,
  104. NUMERICAL,
  105. OTHER_FAULT,
  106. FAILED,
  107. BAD_COMMAND,
  108. COMPLETED
  109. };
  110. /**
  111. * Generate the Dart compatible output
  112. */
  113. virtual void GenerateDartOutput(std::ostream& os);
  114. /**
  115. * Run the test for a directory and any subdirectories
  116. */
  117. void ProcessDirectory(std::vector<cmStdString> &passed,
  118. std::vector<cmStdString> &failed);
  119. typedef std::vector<cmCTestTestProperties> ListOfTests;
  120. /**
  121. * Get the list of tests in directory and subdirectories.
  122. */
  123. void GetListOfTests();
  124. /**
  125. * Find the executable for a test
  126. */
  127. std::string FindTheExecutable(const char *exe);
  128. const char* GetTestStatus(int status);
  129. void ExpandTestsToRunInformation(int numPossibleTests);
  130. std::vector<cmStdString> CustomPreTest;
  131. std::vector<cmStdString> CustomPostTest;
  132. std::vector<int> TestsToRun;
  133. bool UseIncludeRegExpFlag;
  134. bool UseExcludeRegExpFlag;
  135. bool UseExcludeRegExpFirst;
  136. std::string IncludeRegExp;
  137. std::string ExcludeRegExp;
  138. cmsys::RegularExpression IncludeTestsRegularExpression;
  139. cmsys::RegularExpression ExcludeTestsRegularExpression;
  140. std::string GenerateRegressionImages(const std::string& xml);
  141. std::string TestsToRunString;
  142. bool UseUnion;
  143. ListOfTests TestList;
  144. cmsys::RegularExpression DartStuff;
  145. std::ostream* LogFile;
  146. };
  147. #endif