2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc.
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
#ifndef cmCTestScriptHandler_h
|
|
|
|
#define cmCTestScriptHandler_h
|
|
|
|
|
|
|
|
|
2005-01-27 19:43:22 +03:00
|
|
|
#include "cmCTestGenericHandler.h"
|
2004-09-06 20:45:14 +04:00
|
|
|
#include "cmListFileCache.h"
|
|
|
|
|
|
|
|
class cmMakefile;
|
2004-09-07 17:17:15 +04:00
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmake;
|
2005-02-17 18:51:52 +03:00
|
|
|
class cmCTestCommand;
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
/** \class cmCTestScriptHandler
|
|
|
|
* \brief A class that handles ctest -S invocations
|
|
|
|
*
|
2004-09-28 17:00:06 +04:00
|
|
|
* CTest script is controlled using several variables that script has to
|
|
|
|
* specify and some optional ones. Required ones are:
|
|
|
|
* CTEST_SOURCE_DIRECTORY - Source directory of the project
|
|
|
|
* CTEST_BINARY_DIRECTORY - Binary directory of the project
|
|
|
|
* CTEST_COMMAND - Testing commands
|
|
|
|
*
|
|
|
|
* Optional variables are:
|
|
|
|
* CTEST_BACKUP_AND_RESTORE
|
|
|
|
* CTEST_CMAKE_COMMAND
|
|
|
|
* CTEST_CMAKE_OUTPUT_FILE_NAME
|
|
|
|
* CTEST_CONTINUOUS_DURATION
|
|
|
|
* CTEST_CONTINUOUS_MINIMUM_INTERVAL
|
|
|
|
* CTEST_CVS_CHECKOUT
|
|
|
|
* CTEST_CVS_COMMAND
|
2006-04-30 04:13:05 +04:00
|
|
|
* CTEST_UPDATE_COMMAND
|
2004-09-28 17:00:06 +04:00
|
|
|
* CTEST_DASHBOARD_ROOT
|
|
|
|
* CTEST_ENVIRONMENT
|
|
|
|
* CTEST_INITIAL_CACHE
|
|
|
|
* CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
|
|
|
|
* CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
|
2006-03-10 23:03:09 +03:00
|
|
|
*
|
2005-11-22 23:15:52 +03:00
|
|
|
* In addition the following variables can be used. The number can be 1-10.
|
2004-09-28 17:00:06 +04:00
|
|
|
* CTEST_EXTRA_UPDATES_1
|
|
|
|
* CTEST_EXTRA_UPDATES_2
|
|
|
|
* ...
|
|
|
|
* CTEST_EXTRA_UPDATES_10
|
|
|
|
*
|
|
|
|
* CTest script can use the following arguments CTest provides:
|
|
|
|
* CTEST_SCRIPT_ARG
|
|
|
|
* CTEST_SCRIPT_DIRECTORY
|
|
|
|
* CTEST_SCRIPT_NAME
|
|
|
|
*
|
2004-09-06 20:45:14 +04:00
|
|
|
*/
|
2005-01-27 19:43:22 +03:00
|
|
|
class cmCTestScriptHandler : public cmCTestGenericHandler
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
|
|
|
public:
|
2005-06-17 21:04:56 +04:00
|
|
|
cmTypeMacro(cmCTestScriptHandler, cmCTestGenericHandler);
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
/**
|
2006-04-04 21:04:28 +04:00
|
|
|
* Add a script to run, and if is should run in the current process
|
2004-09-06 20:45:14 +04:00
|
|
|
*/
|
2006-04-04 21:04:28 +04:00
|
|
|
void AddConfigurationScript(const char *, bool pscope);
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
/**
|
|
|
|
* Run a dashboard using a specified confiuration script
|
|
|
|
*/
|
2005-01-27 23:54:47 +03:00
|
|
|
int ProcessHandler();
|
2005-01-27 18:11:04 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Run a script
|
|
|
|
*/
|
2009-09-04 21:24:25 +04:00
|
|
|
static bool RunScript(cmCTest* ctest, const char *script, bool InProcess,
|
|
|
|
int* returnValue);
|
2005-01-27 19:01:56 +03:00
|
|
|
int RunCurrentScript();
|
2006-03-10 23:03:09 +03:00
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
/*
|
|
|
|
* Empty Binary Directory
|
|
|
|
*/
|
|
|
|
static bool EmptyBinaryDirectory(const char *dir);
|
|
|
|
|
2009-07-12 00:30:18 +04:00
|
|
|
/*
|
|
|
|
* Write an initial CMakeCache.txt from the given contents.
|
|
|
|
*/
|
|
|
|
static bool WriteInitialCache(const char* directory, const char* text);
|
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
/*
|
|
|
|
* Some elapsed time handling functions
|
|
|
|
*/
|
|
|
|
static void SleepInSeconds(unsigned int secondsToWait);
|
|
|
|
void UpdateElapsedTime();
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
/**
|
2006-10-19 18:45:19 +04:00
|
|
|
* Return the time remaianing that the script is allowed to run in
|
|
|
|
* seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
|
|
|
|
* not been set it returns 1e7 seconds
|
|
|
|
*/
|
|
|
|
double GetRemainingTimeAllowed();
|
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
cmCTestScriptHandler();
|
2004-09-06 22:17:20 +04:00
|
|
|
~cmCTestScriptHandler();
|
2006-03-10 23:03:09 +03:00
|
|
|
|
2005-06-17 21:04:56 +04:00
|
|
|
void Initialize();
|
2006-04-04 21:04:28 +04:00
|
|
|
|
2007-06-09 00:06:33 +04:00
|
|
|
void CreateCMake();
|
2009-01-09 20:05:23 +03:00
|
|
|
cmake* GetCMake() { return this->CMake;}
|
2004-09-06 20:45:14 +04:00
|
|
|
private:
|
|
|
|
// reads in a script
|
2005-01-27 19:43:22 +03:00
|
|
|
int ReadInScript(const std::string& total_script_arg);
|
2006-04-04 21:04:28 +04:00
|
|
|
int ExecuteScript(const std::string& total_script_arg);
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// extract vars from the script to set ivars
|
|
|
|
int ExtractVariables();
|
|
|
|
|
|
|
|
// perform a CVS checkout of the source dir
|
|
|
|
int CheckOutSourceDir();
|
|
|
|
|
|
|
|
// perform any extra cvs updates that were requested
|
|
|
|
int PerformExtraUpdates();
|
2006-03-10 23:03:09 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// backup and restore dirs
|
|
|
|
int BackupDirectories();
|
|
|
|
void RestoreBackupDirectories();
|
|
|
|
|
2006-04-04 21:04:28 +04:00
|
|
|
int RunConfigurationScript(const std::string& script, bool pscope);
|
2004-09-06 20:45:14 +04:00
|
|
|
int RunConfigurationDashboard();
|
|
|
|
|
2005-02-17 18:51:52 +03:00
|
|
|
// Add ctest command
|
|
|
|
void AddCTestCommand(cmCTestCommand* command);
|
|
|
|
|
2013-11-02 00:55:45 +04:00
|
|
|
// Try to remove the binary directory once
|
|
|
|
static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath);
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> ConfigurationScripts;
|
2006-04-04 21:04:28 +04:00
|
|
|
std::vector<bool> ScriptProcessScope;
|
2006-03-10 23:03:09 +03:00
|
|
|
|
|
|
|
bool Backup;
|
|
|
|
bool EmptyBinDir;
|
|
|
|
bool EmptyBinDirOnce;
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string SourceDir;
|
|
|
|
std::string BinaryDir;
|
|
|
|
std::string BackupSourceDir;
|
|
|
|
std::string BackupBinaryDir;
|
|
|
|
std::string CTestRoot;
|
|
|
|
std::string CVSCheckOut;
|
|
|
|
std::string CTestCmd;
|
|
|
|
std::string UpdateCmd;
|
|
|
|
std::string CTestEnv;
|
|
|
|
std::string InitialCache;
|
|
|
|
std::string CMakeCmd;
|
|
|
|
std::string CMOutFile;
|
|
|
|
std::vector<std::string> ExtraUpdates;
|
2006-03-10 23:03:09 +03:00
|
|
|
|
|
|
|
double MinimumInterval;
|
|
|
|
double ContinuousDuration;
|
2005-01-27 18:11:04 +03:00
|
|
|
|
|
|
|
// what time in seconds did this script start running
|
2006-03-10 23:03:09 +03:00
|
|
|
double ScriptStartTime;
|
|
|
|
|
|
|
|
cmMakefile *Makefile;
|
|
|
|
cmGlobalGenerator *GlobalGenerator;
|
|
|
|
cmake *CMake;
|
2004-09-06 20:45:14 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|