1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestTestHandler.h,v $
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>
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 struct cmCTestTestProperties
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
;
93 struct cmCTestTestResult
97 std::string FullCommandLine
;
101 std::string CompletionStatus
;
103 std::string RegressionImages
;
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
);
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
;
140 int CustomMaximumPassedTestOutputSize
;
141 int CustomMaximumFailedTestOutputSize
;
146 virtual void ProcessOneTest(cmCTestTestProperties
*props
,
147 std::vector
<cmStdString
> &passed
,
148 std::vector
<cmStdString
> &failed
,
149 int count
, int tmsize
);
154 enum { // Program statuses
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
;
210 ListOfTests TestList
;
211 cmsys::RegularExpression DartStuff
;
213 std::ostream
* LogFile
;