cmCTest.h 4.2 KB

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