1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestTestHandler.h,v $
6 Date: $Date: 2009-09-10 15:16:08 $
7 Version: $Revision: 1.49 $
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>
27 /** \class cmCTestTestHandler
28 * \brief A class that handles ctest -S invocations
31 class cmCTestTestHandler
: public cmCTestGenericHandler
33 friend class cmCTestRunTest
;
34 friend class cmCTestMultiProcessHandler
;
35 friend class cmCTestBatchTestHandler
;
37 cmTypeMacro(cmCTestTestHandler
, cmCTestGenericHandler
);
40 * The main entry point for this class
45 * When both -R and -I are used should te resulting test list be the
46 * intersection or the union of the lists. By default it is the
49 void SetUseUnion(bool val
) { this->UseUnion
= val
; }
52 * This method is called when reading CTest custom file
54 void PopulateCustomVectors(cmMakefile
*mf
);
56 ///! Control the use of the regular expresisons, call these methods to turn
58 void UseIncludeRegExp();
59 void UseExcludeRegExp();
60 void SetIncludeRegExp(const char *);
61 void SetExcludeRegExp(const char *);
63 void SetMaxIndex(int n
) {this->MaxIndex
= n
;}
64 int GetMaxIndex() {return this->MaxIndex
;}
66 ///! pass the -I argument down
67 void SetTestsToRunInformation(const char*);
72 * Add the test to the list of tests to be executed
74 bool AddTest(const std::vector
<std::string
>& args
);
77 * Set tests properties
79 bool SetTestsProperties(const std::vector
<std::string
>& args
);
83 // NOTE: This struct is Saved/Restored
84 // in cmCTestTestHandler, if you add to this class
85 // then you must add the new members to that code or
86 // ctest -j N will break for that feature
87 struct cmCTestTestProperties
90 cmStdString Directory
;
91 std::vector
<std::string
> Args
;
92 std::vector
<std::string
> Depends
;
93 std::vector
<std::pair
<cmsys::RegularExpression
,
94 std::string
> > ErrorRegularExpressions
;
95 std::vector
<std::pair
<cmsys::RegularExpression
,
96 std::string
> > RequiredRegularExpressions
;
97 std::map
<cmStdString
, cmStdString
> Measurements
;
98 bool IsInBasedOnREOptions
;
104 //Requested number of process slots
106 std::vector
<std::string
> Environment
;
107 std::vector
<std::string
> Labels
;
110 struct cmCTestTestResult
115 std::string FullCommandLine
;
116 double ExecutionTime
;
119 std::string CompletionStatus
;
121 std::string RegressionImages
;
123 cmCTestTestProperties
* Properties
;
126 // add configuraitons to a search path for an executable
127 static void AddConfigurations(cmCTest
*ctest
,
128 std::vector
<std::string
> &attempted
,
129 std::vector
<std::string
> &attemptedConfigs
,
130 std::string filepath
,
131 std::string
&filename
);
133 // full signature static method to find an executable
134 static std::string
FindExecutable(cmCTest
*ctest
,
135 const char *testCommand
,
136 std::string
&resultingConfig
,
137 std::vector
<std::string
> &extraPaths
,
138 std::vector
<std::string
> &failed
);
140 typedef std::vector
<cmCTestTestProperties
> ListOfTests
;
142 // comput a final test list
143 virtual int PreProcessHandler();
144 virtual int PostProcessHandler();
145 virtual void GenerateTestCommand(std::vector
<std::string
>& args
);
146 int ExecuteCommands(std::vector
<cmStdString
>& vec
);
148 void WriteTestResultHeader(std::ostream
& os
, cmCTestTestResult
* result
);
149 void WriteTestResultFooter(std::ostream
& os
, cmCTestTestResult
* result
);
151 //! Clean test output to specified length
152 bool CleanTestOutput(std::string
& output
, size_t length
);
154 double ElapsedTestingTime
;
156 typedef std::vector
<cmCTestTestResult
> TestResultsVector
;
157 TestResultsVector TestResults
;
159 std::vector
<cmStdString
> CustomTestsIgnore
;
160 std::string StartTest
;
162 unsigned int StartTestTime
;
163 unsigned int EndTestTime
;
165 int CustomMaximumPassedTestOutputSize
;
166 int CustomMaximumFailedTestOutputSize
;
169 enum { // Program statuses
184 * Generate the Dart compatible output
186 virtual void GenerateDartOutput(std::ostream
& os
);
188 void PrintLabelSummary();
190 * Run the tests for a directory and any subdirectories
192 void ProcessDirectory(std::vector
<cmStdString
> &passed
,
193 std::vector
<cmStdString
> &failed
);
196 * Get the list of tests in directory and subdirectories.
198 void GetListOfTests();
199 // compute the lists of tests that will actually run
200 // based on union regex and -I stuff
201 void ComputeTestList();
203 bool GetValue(const char* tag
,
206 bool GetValue(const char* tag
,
209 bool GetValue(const char* tag
,
212 bool GetValue(const char* tag
,
215 bool GetValue(const char* tag
,
219 * Find the executable for a test
221 std::string
FindTheExecutable(const char *exe
);
223 const char* GetTestStatus(int status
);
224 void ExpandTestsToRunInformation(size_t numPossibleTests
);
226 std::vector
<cmStdString
> CustomPreTest
;
227 std::vector
<cmStdString
> CustomPostTest
;
229 std::vector
<int> TestsToRun
;
231 bool UseIncludeLabelRegExpFlag
;
232 bool UseExcludeLabelRegExpFlag
;
233 bool UseIncludeRegExpFlag
;
234 bool UseExcludeRegExpFlag
;
235 bool UseExcludeRegExpFirst
;
236 std::string IncludeLabelRegExp
;
237 std::string ExcludeLabelRegExp
;
238 std::string IncludeRegExp
;
239 std::string ExcludeRegExp
;
240 cmsys::RegularExpression IncludeLabelRegularExpression
;
241 cmsys::RegularExpression ExcludeLabelRegularExpression
;
242 cmsys::RegularExpression IncludeTestsRegularExpression
;
243 cmsys::RegularExpression ExcludeTestsRegularExpression
;
245 std::string
GenerateRegressionImages(const std::string
& xml
);
246 cmsys::RegularExpression DartStuff1
;
247 void CheckLabelFilter(cmCTestTestProperties
& it
);
248 void CheckLabelFilterExclude(cmCTestTestProperties
& it
);
249 void CheckLabelFilterInclude(cmCTestTestProperties
& it
);
251 std::string TestsToRunString
;
253 ListOfTests TestList
;
254 size_t TotalNumberOfTests
;
255 cmsys::RegularExpression DartStuff
;
257 std::ostream
* LogFile
;