cmCTestTestHandler.h 4.1 KB

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