ENH: keep cleaning up Tcl/Tk modules
[cmake.git] / Source / CTest / cmCTestTestHandler.h
blob6d7bd0c8ddea6fde0e281da2df12b9d12d740a11
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestTestHandler.h,v $
5 Language: C++
6 Date: $Date: 2007-09-24 15:10:55 $
7 Version: $Revision: 1.26 $
9 Copyright (c) 2002 Kitware, Inc. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #ifndef cmCTestTestHandler_h
19 #define cmCTestTestHandler_h
22 #include "cmCTestGenericHandler.h"
23 #include <cmsys/RegularExpression.hxx>
25 class cmMakefile;
27 /** \class cmCTestTestHandler
28 * \brief A class that handles ctest -S invocations
31 class cmCTestTestHandler : public cmCTestGenericHandler
33 public:
34 cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
36 /**
37 * The main entry point for this class
39 int ProcessHandler();
41 /**
42 * When both -R and -I are used should te resulting test list be the
43 * intersection or the union of the lists. By default it is the
44 * intersection.
46 void SetUseUnion(bool val) { this->UseUnion = val; }
48 /**
49 * This method is called when reading CTest custom file
51 void PopulateCustomVectors(cmMakefile *mf);
53 ///! Control the use of the regular expresisons, call these methods to turn
54 ///them on
55 void UseIncludeRegExp();
56 void UseExcludeRegExp();
57 void SetIncludeRegExp(const char *);
58 void SetExcludeRegExp(const char *);
61 ///! pass the -I argument down
62 void SetTestsToRunInformation(const char*);
64 cmCTestTestHandler();
67 * Add the test to the list of tests to be executed
69 bool AddTest(const std::vector<std::string>& args);
72 * Set tests properties
74 bool SetTestsProperties(const std::vector<std::string>& args);
76 void Initialize();
78 struct cmCTestTestProperties
80 cmStdString Name;
81 cmStdString Directory;
82 std::vector<std::string> Args;
83 std::vector<std::pair<cmsys::RegularExpression,
84 std::string> > ErrorRegularExpressions;
85 std::vector<std::pair<cmsys::RegularExpression,
86 std::string> > RequiredRegularExpressions;
87 std::map<cmStdString, cmStdString> Measurements;
88 bool IsInBasedOnREOptions;
89 bool WillFail;
90 double Timeout;
93 struct cmCTestTestResult
95 std::string Name;
96 std::string Path;
97 std::string FullCommandLine;
98 double ExecutionTime;
99 int ReturnValue;
100 int Status;
101 std::string CompletionStatus;
102 std::string Output;
103 std::string RegressionImages;
104 int TestCount;
105 cmCTestTestProperties* Properties;
108 // add configuraitons to a search path for an executable
109 static void AddConfigurations(cmCTest *ctest,
110 std::vector<std::string> &attempted,
111 std::vector<std::string> &attemptedConfigs,
112 std::string filepath,
113 std::string &filename);
115 // full signature static method to find an executable
116 static std::string FindExecutable(cmCTest *ctest,
117 const char *testCommand,
118 std::string &resultingConfig,
119 std::vector<std::string> &extraPaths,
120 std::vector<std::string> &failed);
122 protected:
123 virtual int PreProcessHandler();
124 virtual int PostProcessHandler();
125 virtual void GenerateTestCommand(std::vector<const char*>& args);
126 int ExecuteCommands(std::vector<cmStdString>& vec);
128 //! Clean test output to specified length
129 bool CleanTestOutput(std::string& output, size_t length);
131 double ElapsedTestingTime;
133 typedef std::vector<cmCTestTestResult> TestResultsVector;
134 TestResultsVector TestResults;
136 std::vector<cmStdString> CustomTestsIgnore;
137 std::string StartTest;
138 std::string EndTest;
139 bool MemCheck;
140 int CustomMaximumPassedTestOutputSize;
141 int CustomMaximumFailedTestOutputSize;
142 protected:
144 * Run one test
146 virtual void ProcessOneTest(cmCTestTestProperties *props,
147 std::vector<cmStdString> &passed,
148 std::vector<cmStdString> &failed,
149 int count, int tmsize);
153 private:
154 enum { // Program statuses
155 NOT_RUN = 0,
156 TIMEOUT,
157 SEGFAULT,
158 ILLEGAL,
159 INTERRUPT,
160 NUMERICAL,
161 OTHER_FAULT,
162 FAILED,
163 BAD_COMMAND,
164 COMPLETED
169 * Generate the Dart compatible output
171 virtual void GenerateDartOutput(std::ostream& os);
174 * Run the tests for a directory and any subdirectories
176 void ProcessDirectory(std::vector<cmStdString> &passed,
177 std::vector<cmStdString> &failed);
179 typedef std::vector<cmCTestTestProperties> ListOfTests;
181 * Get the list of tests in directory and subdirectories.
183 void GetListOfTests();
186 * Find the executable for a test
188 std::string FindTheExecutable(const char *exe);
190 const char* GetTestStatus(int status);
191 void ExpandTestsToRunInformation(int numPossibleTests);
193 std::vector<cmStdString> CustomPreTest;
194 std::vector<cmStdString> CustomPostTest;
196 std::vector<int> TestsToRun;
198 bool UseIncludeRegExpFlag;
199 bool UseExcludeRegExpFlag;
200 bool UseExcludeRegExpFirst;
201 std::string IncludeRegExp;
202 std::string ExcludeRegExp;
203 cmsys::RegularExpression IncludeTestsRegularExpression;
204 cmsys::RegularExpression ExcludeTestsRegularExpression;
206 std::string GenerateRegressionImages(const std::string& xml);
208 std::string TestsToRunString;
209 bool UseUnion;
210 ListOfTests TestList;
211 cmsys::RegularExpression DartStuff;
213 std::ostream* LogFile;
216 #endif