ctest.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 ctest
  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. * Do revision control update of directory
  43. */
  44. int UpdateDirectory();
  45. /**
  46. * Do configure the project
  47. */
  48. int ConfigureDirectory();
  49. /**
  50. * Run the test for a directory and any subdirectories
  51. */
  52. void ProcessDirectory(std::vector<std::string> &passed,
  53. std::vector<std::string> &failed);
  54. /**
  55. * Find the executable for a test
  56. */
  57. std::string FindExecutable(const char *exe);
  58. /**
  59. * Set the cmake test
  60. */
  61. bool SetTest(const char*);
  62. /**
  63. * constructor
  64. */
  65. ctest();
  66. bool m_UseIncludeRegExp;
  67. std::string m_IncludeRegExp;
  68. bool m_UseExcludeRegExp;
  69. bool m_UseExcludeRegExpFirst;
  70. std::string m_ExcludeRegExp;
  71. std::string m_ConfigType;
  72. bool m_Verbose;
  73. bool m_DartMode;
  74. private:
  75. enum {
  76. FIRST_TEST = 0,
  77. UPDATE_TEST,
  78. CONFIGURE_TEST,
  79. BUILD_TEST,
  80. TEST_TEST,
  81. COVERAGE_TEST,
  82. PURIFY_TEST,
  83. ALL_TEST,
  84. LAST_TEST
  85. };
  86. struct cmCTestTestResult
  87. {
  88. std::string m_Name;
  89. std::string m_Path;
  90. std::string m_FullCommandLine;
  91. double m_ExecutionTime;
  92. int m_ReturnValue;
  93. std::string m_CompletionStatus;
  94. std::string m_Output;
  95. };
  96. struct cmCTestBuildErrorWarning
  97. {
  98. bool m_Error;
  99. int m_LogLine;
  100. std::string m_Text;
  101. std::string m_SourceFile;
  102. std::string m_SourceFileTail;
  103. int m_LineNumber;
  104. std::string m_PreContext;
  105. std::string m_PostContext;
  106. };
  107. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  108. typedef std::map<std::string, std::string> tm_DartConfigurationMap;
  109. tm_TestResultsVector m_TestResults;
  110. std::string m_ToplevelPath;
  111. tm_DartConfigurationMap m_DartConfiguration;
  112. int m_Tests[LAST_TEST];
  113. std::string m_CurrentTag;
  114. std::string m_StartBuild;
  115. std::string m_EndBuild;
  116. std::string m_StartTest;
  117. std::string m_EndTest;
  118. /**
  119. * Generate the Dart compatible output
  120. */
  121. void GenerateDartOutput(std::ostream& os);
  122. void GenerateDartBuildOutput(std::ostream& os,
  123. std::vector<cmCTestBuildErrorWarning>);
  124. bool OpenFile(const std::string& path,
  125. const std::string& name, std::ofstream& stream);
  126. std::string MakeXMLSafe(const std::string&);
  127. };