1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestScriptHandler.h,v $
6 <<<<<<< cmCTestScriptHandler.h
7 Date: $Date: 2007/06/08 20:06:33 $
8 Version: $Revision: 1.19 $
10 Date: $Date: 2009-01-09 17:05:23 $
11 Version: $Revision: 1.20 $
14 Copyright (c) 2002 Kitware, Inc. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
23 #ifndef cmCTestScriptHandler_h
24 #define cmCTestScriptHandler_h
27 #include "cmCTestGenericHandler.h"
28 #include "cmListFileCache.h"
31 class cmLocalGenerator
;
32 class cmGlobalGenerator
;
36 /** \class cmCTestScriptHandler
37 * \brief A class that handles ctest -S invocations
39 * CTest script is controlled using several variables that script has to
40 * specify and some optional ones. Required ones are:
41 * CTEST_SOURCE_DIRECTORY - Source directory of the project
42 * CTEST_BINARY_DIRECTORY - Binary directory of the project
43 * CTEST_COMMAND - Testing commands
45 * Optional variables are:
46 * CTEST_BACKUP_AND_RESTORE
48 * CTEST_CMAKE_OUTPUT_FILE_NAME
49 * CTEST_CONTINUOUS_DURATION
50 * CTEST_CONTINUOUS_MINIMUM_INTERVAL
53 * CTEST_UPDATE_COMMAND
54 * CTEST_DASHBOARD_ROOT
57 * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
58 * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
60 * In addition the following variables can be used. The number can be 1-10.
61 * CTEST_EXTRA_UPDATES_1
62 * CTEST_EXTRA_UPDATES_2
64 * CTEST_EXTRA_UPDATES_10
66 * CTest script can use the following arguments CTest provides:
68 * CTEST_SCRIPT_DIRECTORY
72 class cmCTestScriptHandler
: public cmCTestGenericHandler
75 cmTypeMacro(cmCTestScriptHandler
, cmCTestGenericHandler
);
78 * Add a script to run, and if is should run in the current process
80 void AddConfigurationScript(const char *, bool pscope
);
83 * Run a dashboard using a specified confiuration script
90 static bool RunScript(cmCTest
* ctest
, const char *script
, bool InProcess
);
91 int RunCurrentScript();
94 * Empty Binary Directory
96 static bool EmptyBinaryDirectory(const char *dir
);
99 * Some elapsed time handling functions
101 static void SleepInSeconds(unsigned int secondsToWait
);
102 void UpdateElapsedTime();
105 * Return the time remaianing that the script is allowed to run in
106 * seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
107 * not been set it returns 1e7 seconds
109 double GetRemainingTimeAllowed();
111 cmCTestScriptHandler();
112 ~cmCTestScriptHandler();
117 void GetCommandDocumentation(std::vector
<cmDocumentationEntry
>& v
) const;
118 cmake
* GetCMake() { return this->CMake
;}
121 int ReadInScript(const std::string
& total_script_arg
);
122 int ExecuteScript(const std::string
& total_script_arg
);
124 // extract vars from the script to set ivars
125 int ExtractVariables();
127 // perform a CVS checkout of the source dir
128 int CheckOutSourceDir();
130 // perform any extra cvs updates that were requested
131 int PerformExtraUpdates();
133 // backup and restore dirs
134 int BackupDirectories();
135 void RestoreBackupDirectories();
137 int RunConfigurationScript(const std::string
& script
, bool pscope
);
138 int RunConfigurationDashboard();
141 void AddCTestCommand(cmCTestCommand
* command
);
143 std::vector
<cmStdString
> ConfigurationScripts
;
144 std::vector
<bool> ScriptProcessScope
;
148 bool EmptyBinDirOnce
;
150 cmStdString SourceDir
;
151 cmStdString BinaryDir
;
152 cmStdString BackupSourceDir
;
153 cmStdString BackupBinaryDir
;
154 cmStdString CTestRoot
;
155 cmStdString CVSCheckOut
;
156 cmStdString CTestCmd
;
157 cmStdString UpdateCmd
;
158 cmStdString CTestEnv
;
159 cmStdString InitCache
;
160 cmStdString CMakeCmd
;
161 cmStdString CMOutFile
;
162 std::vector
<cmStdString
> ExtraUpdates
;
164 double MinimumInterval
;
165 double ContinuousDuration
;
167 // what time in seconds did this script start running
168 double ScriptStartTime
;
170 cmMakefile
*Makefile
;
171 cmLocalGenerator
*LocalGenerator
;
172 cmGlobalGenerator
*GlobalGenerator
;