cmCTest.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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., Insight Consortium. 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 cmCTest_h
  14. #define cmCTest_h
  15. #include "cmStandardIncludes.h"
  16. class cmCTest
  17. {
  18. public:
  19. /**
  20. * Initialize and finalize testing
  21. */
  22. void Initialize();
  23. void Finalize();
  24. /**
  25. * Process the tests. This is the main routine. The execution of the
  26. * tests should look like this:
  27. *
  28. * ctest foo;
  29. * foo.Initialize();
  30. * // Set some things on foo
  31. * foo.ProcessTests();
  32. * foo.Finalize();
  33. */
  34. int ProcessTests();
  35. /**
  36. * Try to build the project
  37. */
  38. int BuildDirectory();
  39. /**
  40. * Try to run tests of the project
  41. */
  42. int TestDirectory();
  43. /**
  44. * Try to get coverage of the project
  45. */
  46. int CoverageDirectory();
  47. /**
  48. * Do revision control update of directory
  49. */
  50. int UpdateDirectory();
  51. /**
  52. * Do configure the project
  53. */
  54. int ConfigureDirectory();
  55. /**
  56. * Do submit testing results
  57. */
  58. int SubmitResults();
  59. std::string GetSubmitResultsPrefix();
  60. /**
  61. * Check if CTest file exists
  62. */
  63. bool CTestFileExists(const std::string& filename);
  64. /**
  65. * Run the test for a directory and any subdirectories
  66. */
  67. void ProcessDirectory(std::vector<std::string> &passed,
  68. std::vector<std::string> &failed);
  69. /**
  70. * Find the executable for a test
  71. */
  72. std::string FindTheExecutable(const char *exe);
  73. /**
  74. * Set the cmake test
  75. */
  76. bool SetTest(const char*);
  77. /**
  78. * Set the cmake test mode (experimental, nightly, continuous).
  79. */
  80. void SetTestModel(int mode)
  81. {
  82. m_TestModel = mode;
  83. }
  84. std::string GetTestModelString();
  85. /**
  86. * constructor
  87. */
  88. cmCTest();
  89. bool m_UseIncludeRegExp;
  90. std::string m_IncludeRegExp;
  91. bool m_UseExcludeRegExp;
  92. bool m_UseExcludeRegExpFirst;
  93. std::string m_ExcludeRegExp;
  94. std::string m_ConfigType;
  95. bool m_Verbose;
  96. bool m_DartMode;
  97. bool m_ShowOnly;
  98. enum {
  99. EXPERIMENTAL,
  100. NIGHTLY,
  101. CONTINUOUS
  102. };
  103. private:
  104. enum {
  105. FIRST_TEST = 0,
  106. UPDATE_TEST = 1,
  107. START_TEST = 2,
  108. CONFIGURE_TEST = 3,
  109. BUILD_TEST = 4,
  110. TEST_TEST = 5,
  111. COVERAGE_TEST = 6,
  112. PURIFY_TEST = 7,
  113. SUBMIT_TEST = 8,
  114. ALL_TEST = 9,
  115. LAST_TEST = 10
  116. };
  117. struct cmCTestTestResult
  118. {
  119. std::string m_Name;
  120. std::string m_Path;
  121. std::string m_FullCommandLine;
  122. double m_ExecutionTime;
  123. int m_ReturnValue;
  124. std::string m_CompletionStatus;
  125. std::string m_Output;
  126. };
  127. struct cmCTestBuildErrorWarning
  128. {
  129. bool m_Error;
  130. int m_LogLine;
  131. std::string m_Text;
  132. std::string m_SourceFile;
  133. std::string m_SourceFileTail;
  134. int m_LineNumber;
  135. std::string m_PreContext;
  136. std::string m_PostContext;
  137. };
  138. // Some structures needed for cvs update
  139. struct StringPair :
  140. public std::pair<std::string, std::string>{};
  141. struct UpdateFiles : public std::vector<StringPair>{};
  142. struct AuthorsToUpdatesMap :
  143. public std::map<std::string, UpdateFiles>{};
  144. struct cmCTestCoverage
  145. {
  146. cmCTestCoverage()
  147. {
  148. m_AbsolutePath = "";
  149. m_FullPath = "";
  150. m_Covered = false;
  151. m_Tested = 0;
  152. m_UnTested = 0;
  153. m_Lines.clear();
  154. m_Show = false;
  155. }
  156. std::string m_AbsolutePath;
  157. std::string m_FullPath;
  158. bool m_Covered;
  159. int m_Tested;
  160. int m_UnTested;
  161. std::vector<int> m_Lines;
  162. bool m_Show;
  163. };
  164. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  165. typedef std::map<std::string, std::string> tm_DartConfigurationMap;
  166. typedef std::map<std::string, cmCTestCoverage> tm_CoverageMap;
  167. tm_TestResultsVector m_TestResults;
  168. std::string m_ToplevelPath;
  169. tm_DartConfigurationMap m_DartConfiguration;
  170. int m_Tests[LAST_TEST];
  171. std::string m_CurrentTag;
  172. std::string m_StartBuild;
  173. std::string m_EndBuild;
  174. std::string m_StartTest;
  175. std::string m_EndTest;
  176. int m_TestModel;
  177. int m_TimeOut;
  178. /**
  179. * Generate the Dart compatible output
  180. */
  181. void GenerateDartOutput(std::ostream& os);
  182. void GenerateDartBuildOutput(std::ostream& os,
  183. std::vector<cmCTestBuildErrorWarning>);
  184. bool OpenOutputFile(const std::string& path,
  185. const std::string& name, std::ofstream& stream);
  186. std::string MakeXMLSafe(const std::string&);
  187. std::string MakeURLSafe(const std::string&);
  188. };
  189. #endif