1
0

cmCTest.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. * Run the test for a directory and any subdirectories
  55. */
  56. void ProcessDirectory(std::vector<std::string> &passed,
  57. std::vector<std::string> &failed);
  58. /**
  59. * Find the executable for a test
  60. */
  61. std::string FindExecutable(const char *exe);
  62. /**
  63. * Set the cmake test
  64. */
  65. bool SetTest(const char*);
  66. /**
  67. * constructor
  68. */
  69. cmCTest();
  70. bool m_UseIncludeRegExp;
  71. std::string m_IncludeRegExp;
  72. bool m_UseExcludeRegExp;
  73. bool m_UseExcludeRegExpFirst;
  74. std::string m_ExcludeRegExp;
  75. std::string m_ConfigType;
  76. bool m_Verbose;
  77. bool m_DartMode;
  78. bool m_ShowOnly;
  79. private:
  80. enum {
  81. FIRST_TEST = 0,
  82. UPDATE_TEST,
  83. CONFIGURE_TEST,
  84. BUILD_TEST,
  85. TEST_TEST,
  86. COVERAGE_TEST,
  87. PURIFY_TEST,
  88. ALL_TEST,
  89. LAST_TEST
  90. };
  91. struct cmCTestTestResult
  92. {
  93. std::string m_Name;
  94. std::string m_Path;
  95. std::string m_FullCommandLine;
  96. double m_ExecutionTime;
  97. int m_ReturnValue;
  98. std::string m_CompletionStatus;
  99. std::string m_Output;
  100. };
  101. struct cmCTestBuildErrorWarning
  102. {
  103. bool m_Error;
  104. int m_LogLine;
  105. std::string m_Text;
  106. std::string m_SourceFile;
  107. std::string m_SourceFileTail;
  108. int m_LineNumber;
  109. std::string m_PreContext;
  110. std::string m_PostContext;
  111. };
  112. struct cmCTestCoverage
  113. {
  114. cmCTestCoverage()
  115. {
  116. m_FullPath = "";
  117. m_Covered = false;
  118. m_Tested = 0;
  119. m_UnTested = 0;
  120. m_Lines.clear();
  121. }
  122. std::string m_FullPath;
  123. bool m_Covered;
  124. int m_Tested;
  125. int m_UnTested;
  126. std::vector<int> m_Lines;
  127. };
  128. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  129. typedef std::map<std::string, std::string> tm_DartConfigurationMap;
  130. typedef std::map<std::string, cmCTestCoverage> tm_CoverageMap;
  131. tm_TestResultsVector m_TestResults;
  132. std::string m_ToplevelPath;
  133. tm_DartConfigurationMap m_DartConfiguration;
  134. int m_Tests[LAST_TEST];
  135. std::string m_CurrentTag;
  136. std::string m_StartBuild;
  137. std::string m_EndBuild;
  138. std::string m_StartTest;
  139. std::string m_EndTest;
  140. /**
  141. * Generate the Dart compatible output
  142. */
  143. void GenerateDartOutput(std::ostream& os);
  144. void GenerateDartBuildOutput(std::ostream& os,
  145. std::vector<cmCTestBuildErrorWarning>);
  146. bool OpenOutputFile(const std::string& path,
  147. const std::string& name, std::ofstream& stream);
  148. std::string MakeXMLSafe(const std::string&);
  149. };