cmCTest.h 4 KB
Newer Older
1
2
/*=========================================================================

3
  Program:   CMake - Cross-Platform Makefile Generator
4
5
6
7
8
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

9
10
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
11

Will Schroeder's avatar
Will Schroeder committed
12
13
14
     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.
15
16
17
18
19

=========================================================================*/


#include "cmStandardIncludes.h"
Bill Hoffman's avatar
Bill Hoffman committed
20

21
class cmCTest
22
23
{
public:
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  /**
   * Initialize and finalize testing
   */
  void Initialize();
  void Finalize();

  /**
   * Process the tests. This is the main routine. The execution of the
   * tests should look like this:
   *
   * ctest foo;
   * foo.Initialize();
   * // Set some things on foo
   * foo.ProcessTests();
   * foo.Finalize();
   */
  int ProcessTests();

  /**
   * Try to build the project
   */
45
46
47
48
49
50
  int BuildDirectory();

  /**
   * Try to run tests of the project
   */
  int TestDirectory();
51

Andy Cedilnik's avatar
Andy Cedilnik committed
52
53
54
55
56
  /**
   * Try to get coverage of the project
   */
  int CoverageDirectory();

57
58
59
  /**
   * Do revision control update of directory
   */
60
  int UpdateDirectory();
61

62
63
64
  /**
   * Do configure the project
   */
65
  int ConfigureDirectory();
66

67
68
69
  /**
   * Run the test for a directory and any subdirectories
   */
70
71
  void ProcessDirectory(std::vector<std::string> &passed, 
                        std::vector<std::string> &failed);
72
73
74
75
76
77

  /**
   * Find the executable for a test
   */
  std::string FindExecutable(const char *exe);

78
79
80
81
82
  /**
   * Set the cmake test
   */
  bool SetTest(const char*);

83
84
85
  /**
   * constructor
   */
86
  cmCTest();
87
88
89
90
91
92
93

  bool m_UseIncludeRegExp;
  std::string m_IncludeRegExp;

  bool m_UseExcludeRegExp;
  bool m_UseExcludeRegExpFirst;
  std::string m_ExcludeRegExp;
Ken Martin's avatar
Ken Martin committed
94

95
  std::string m_ConfigType;
96
  bool m_Verbose;
97
  bool m_DartMode;
98
  bool m_ShowOnly;
99

100
private:
101
102
103
  enum {
    FIRST_TEST    = 0,
    UPDATE_TEST,
104
    CONFIGURE_TEST,
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    BUILD_TEST,
    TEST_TEST,
    COVERAGE_TEST,
    PURIFY_TEST,
    ALL_TEST,
    LAST_TEST
  };

  struct cmCTestTestResult
  {
    std::string m_Name;
    std::string m_Path;
    std::string m_FullCommandLine;
    double      m_ExecutionTime;
    int         m_ReturnValue;
    std::string m_CompletionStatus;
    std::string m_Output;
  };

124
125
126
127
128
129
130
131
132
133
134
135
  struct cmCTestBuildErrorWarning
  {
    bool        m_Error;
    int         m_LogLine;
    std::string m_Text;
    std::string m_SourceFile;
    std::string m_SourceFileTail;
    int         m_LineNumber;
    std::string m_PreContext;
    std::string m_PostContext;
  };

Andy Cedilnik's avatar
Andy Cedilnik committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  struct cmCTestCoverage
  {
    cmCTestCoverage()
      {
        m_FullPath = "";
        m_Covered = false;
        m_Tested = 0;
        m_UnTested = 0;
        m_Lines.clear();
      }
    std::string      m_FullPath;
    bool             m_Covered;
    int              m_Tested;
    int              m_UnTested;
    std::vector<int> m_Lines;
  };

153
154
  typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  typedef std::map<std::string, std::string> tm_DartConfigurationMap;
Andy Cedilnik's avatar
Andy Cedilnik committed
155
  typedef std::map<std::string, cmCTestCoverage> tm_CoverageMap;
156
157
158
159
160

  tm_TestResultsVector    m_TestResults;
  std::string             m_ToplevelPath;
  tm_DartConfigurationMap m_DartConfiguration;
  int                     m_Tests[LAST_TEST];
161
162
  
  std::string             m_CurrentTag;
163

164
165
166
167
  std::string             m_StartBuild;
  std::string             m_EndBuild;
  std::string             m_StartTest;
  std::string             m_EndTest;
168
169
170
171
172
173
174

  /**
   * Generate the Dart compatible output
   */
  void GenerateDartOutput(std::ostream& os);
  void GenerateDartBuildOutput(std::ostream& os, 
                               std::vector<cmCTestBuildErrorWarning>);
175

Andy Cedilnik's avatar
Andy Cedilnik committed
176
177
  bool OpenOutputFile(const std::string& path, 
                      const std::string& name, std::ofstream& stream);  
178
  std::string MakeXMLSafe(const std::string&);
179
180
};