cmCTestTestHandler.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. void Initialize();
  58. struct cmCTestTestProperties
  59. {
  60. cmStdString Name;
  61. cmStdString Directory;
  62. std::vector<std::string> Args;
  63. std::vector<std::pair<cmsys::RegularExpression,
  64. std::string> > ErrorRegularExpressions;
  65. std::vector<std::pair<cmsys::RegularExpression,
  66. std::string> > RequiredRegularExpressions;
  67. std::map<cmStdString, cmStdString> Measurements;
  68. bool IsInBasedOnREOptions;
  69. bool WillFail;
  70. double Timeout;
  71. };
  72. struct cmCTestTestResult
  73. {
  74. std::string Name;
  75. std::string Path;
  76. std::string FullCommandLine;
  77. double ExecutionTime;
  78. int ReturnValue;
  79. int Status;
  80. std::string CompletionStatus;
  81. std::string Output;
  82. std::string RegressionImages;
  83. int TestCount;
  84. cmCTestTestProperties* Properties;
  85. };
  86. // add configuraitons to a search path for an executable
  87. static void AddConfigurations(cmCTest *ctest,
  88. std::vector<std::string> &attempted,
  89. std::vector<std::string> &attemptedConfigs,
  90. std::string filepath,
  91. std::string &filename);
  92. // full signature static method to find an executable
  93. static std::string FindExecutable(cmCTest *ctest,
  94. const char *testCommand,
  95. std::string &resultingConfig,
  96. std::vector<std::string> &extraPaths,
  97. std::vector<std::string> &failed);
  98. protected:
  99. virtual int PreProcessHandler();
  100. virtual int PostProcessHandler();
  101. virtual void GenerateTestCommand(std::vector<const char*>& args);
  102. int ExecuteCommands(std::vector<cmStdString>& vec);
  103. //! Clean test output to specified length
  104. bool CleanTestOutput(std::string& output, size_t length);
  105. double ElapsedTestingTime;
  106. typedef std::vector<cmCTestTestResult> TestResultsVector;
  107. TestResultsVector TestResults;
  108. std::vector<cmStdString> CustomTestsIgnore;
  109. std::string StartTest;
  110. std::string EndTest;
  111. bool MemCheck;
  112. int CustomMaximumPassedTestOutputSize;
  113. int CustomMaximumFailedTestOutputSize;
  114. protected:
  115. /**
  116. * Run one test
  117. */
  118. virtual void ProcessOneTest(cmCTestTestProperties *props,
  119. std::vector<cmStdString> &passed,
  120. std::vector<cmStdString> &failed,
  121. int count, int tmsize);
  122. private:
  123. enum { // Program statuses
  124. NOT_RUN = 0,
  125. TIMEOUT,
  126. SEGFAULT,
  127. ILLEGAL,
  128. INTERRUPT,
  129. NUMERICAL,
  130. OTHER_FAULT,
  131. FAILED,
  132. BAD_COMMAND,
  133. COMPLETED
  134. };
  135. /**
  136. * Generate the Dart compatible output
  137. */
  138. virtual void GenerateDartOutput(std::ostream& os);
  139. /**
  140. * Run the tests for a directory and any subdirectories
  141. */
  142. void ProcessDirectory(std::vector<cmStdString> &passed,
  143. std::vector<cmStdString> &failed);
  144. typedef std::vector<cmCTestTestProperties> ListOfTests;
  145. /**
  146. * Get the list of tests in directory and subdirectories.
  147. */
  148. void GetListOfTests();
  149. /**
  150. * Find the executable for a test
  151. */
  152. std::string FindTheExecutable(const char *exe);
  153. const char* GetTestStatus(int status);
  154. void ExpandTestsToRunInformation(int numPossibleTests);
  155. std::vector<cmStdString> CustomPreTest;
  156. std::vector<cmStdString> CustomPostTest;
  157. std::vector<int> TestsToRun;
  158. bool UseIncludeRegExpFlag;
  159. bool UseExcludeRegExpFlag;
  160. bool UseExcludeRegExpFirst;
  161. std::string IncludeRegExp;
  162. std::string ExcludeRegExp;
  163. cmsys::RegularExpression IncludeTestsRegularExpression;
  164. cmsys::RegularExpression ExcludeTestsRegularExpression;
  165. std::string GenerateRegressionImages(const std::string& xml);
  166. std::string TestsToRunString;
  167. bool UseUnion;
  168. ListOfTests TestList;
  169. cmsys::RegularExpression DartStuff;
  170. std::ostream* LogFile;
  171. };
  172. #endif