1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestTestHandler.h,v $
6 Date: $Date: 2009-02-24 22:23:51 $
7 Version: $Revision: 1.36 $
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
34 cmTypeMacro(cmCTestTestHandler
, cmCTestGenericHandler
);
37 * The main entry point for this class
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
46 void SetUseUnion(bool val
) { this->UseUnion
= val
; }
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
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*);
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
);
78 // NOTE: This struct is Saved/Restored
79 // in cmCTestTestHandler, if you add to this class
80 // then you must add the new members to that code or
81 // ctest -j N will break for that feature
82 struct cmCTestTestProperties
85 cmStdString Directory
;
86 std::vector
<std::string
> Args
;
87 std::vector
<std::string
> Depends
;
88 std::vector
<std::pair
<cmsys::RegularExpression
,
89 std::string
> > ErrorRegularExpressions
;
90 std::vector
<std::pair
<cmsys::RegularExpression
,
91 std::string
> > RequiredRegularExpressions
;
92 std::map
<cmStdString
, cmStdString
> Measurements
;
93 bool IsInBasedOnREOptions
;
97 std::vector
<std::string
> Environment
;
98 std::vector
<std::string
> Labels
;
101 struct cmCTestTestResult
106 std::string FullCommandLine
;
107 double ExecutionTime
;
110 std::string CompletionStatus
;
112 std::string RegressionImages
;
114 cmCTestTestProperties
* Properties
;
117 // add configuraitons to a search path for an executable
118 static void AddConfigurations(cmCTest
*ctest
,
119 std::vector
<std::string
> &attempted
,
120 std::vector
<std::string
> &attemptedConfigs
,
121 std::string filepath
,
122 std::string
&filename
);
124 // full signature static method to find an executable
125 static std::string
FindExecutable(cmCTest
*ctest
,
126 const char *testCommand
,
127 std::string
&resultingConfig
,
128 std::vector
<std::string
> &extraPaths
,
129 std::vector
<std::string
> &failed
);
132 // comput a final test list
133 virtual int PreProcessHandler();
134 virtual int PostProcessHandler();
135 virtual void GenerateTestCommand(std::vector
<const char*>& args
);
136 int ExecuteCommands(std::vector
<cmStdString
>& vec
);
138 void WriteTestResultHeader(std::ostream
& os
, cmCTestTestResult
* result
);
139 void WriteTestResultFooter(std::ostream
& os
, cmCTestTestResult
* result
);
141 //! Clean test output to specified length
142 bool CleanTestOutput(std::string
& output
, size_t length
);
144 double ElapsedTestingTime
;
146 typedef std::vector
<cmCTestTestResult
> TestResultsVector
;
147 TestResultsVector TestResults
;
149 std::vector
<cmStdString
> CustomTestsIgnore
;
150 std::string StartTest
;
152 unsigned int StartTestTime
;
153 unsigned int EndTestTime
;
155 int CustomMaximumPassedTestOutputSize
;
156 int CustomMaximumFailedTestOutputSize
;
161 virtual void ProcessOneTest(cmCTestTestProperties
*props
,
162 std::vector
<cmStdString
> &passed
,
163 std::vector
<cmStdString
> &failed
,
164 int count
, int tmsize
);
169 enum { // Program statuses
184 * Generate the Dart compatible output
186 virtual void GenerateDartOutput(std::ostream
& os
);
189 * Run the tests for a directory and any subdirectories
191 void ProcessDirectory(std::vector
<cmStdString
> &passed
,
192 std::vector
<cmStdString
> &failed
);
194 typedef std::vector
<cmCTestTestProperties
> ListOfTests
;
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 // Save the state of the test list and return the file
204 // name it was saved to
205 std::string
SaveTestList();
207 bool GetValue(const char* tag
,
210 bool GetValue(const char* tag
,
213 bool GetValue(const char* tag
,
216 bool GetValue(const char* tag
,
219 bool GetValue(const char* tag
,
223 void ProcessParallel(std::vector
<cmStdString
> &passed
,
224 std::vector
<cmStdString
> &failed
);
226 * Find the executable for a test
228 std::string
FindTheExecutable(const char *exe
);
230 const char* GetTestStatus(int status
);
231 void ExpandTestsToRunInformation(size_t numPossibleTests
);
233 std::vector
<cmStdString
> CustomPreTest
;
234 std::vector
<cmStdString
> CustomPostTest
;
236 std::vector
<int> TestsToRun
;
238 bool UseIncludeLabelRegExpFlag
;
239 bool UseExcludeLabelRegExpFlag
;
240 bool UseIncludeRegExpFlag
;
241 bool UseExcludeRegExpFlag
;
242 bool UseExcludeRegExpFirst
;
243 std::string IncludeLabelRegExp
;
244 std::string ExcludeLabelRegExp
;
245 std::string IncludeRegExp
;
246 std::string ExcludeRegExp
;
247 cmsys::RegularExpression IncludeLabelRegularExpression
;
248 cmsys::RegularExpression ExcludeLabelRegularExpression
;
249 cmsys::RegularExpression IncludeTestsRegularExpression
;
250 cmsys::RegularExpression ExcludeTestsRegularExpression
;
252 std::string
GenerateRegressionImages(const std::string
& xml
);
253 cmsys::RegularExpression DartStuff1
;
254 void CheckLabelFilter(cmCTestTestProperties
& it
);
255 void CheckLabelFilterExclude(cmCTestTestProperties
& it
);
256 void CheckLabelFilterInclude(cmCTestTestProperties
& it
);
258 std::string TestsToRunString
;
260 ListOfTests TestList
;
261 size_t TotalNumberOfTests
;
262 cmsys::RegularExpression DartStuff
;
264 std::ostream
* LogFile
;