cmCTestScriptHandler.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCTestScriptHandler_h
  14. #define cmCTestScriptHandler_h
  15. #include "cmCTestGenericHandler.h"
  16. #include "cmListFileCache.h"
  17. class cmMakefile;
  18. class cmLocalGenerator;
  19. class cmGlobalGenerator;
  20. class cmake;
  21. class cmCTestCommand;
  22. /** \class cmCTestScriptHandler
  23. * \brief A class that handles ctest -S invocations
  24. *
  25. * CTest script is controlled using several variables that script has to
  26. * specify and some optional ones. Required ones are:
  27. * CTEST_SOURCE_DIRECTORY - Source directory of the project
  28. * CTEST_BINARY_DIRECTORY - Binary directory of the project
  29. * CTEST_COMMAND - Testing commands
  30. *
  31. * Optional variables are:
  32. * CTEST_BACKUP_AND_RESTORE
  33. * CTEST_CMAKE_COMMAND
  34. * CTEST_CMAKE_OUTPUT_FILE_NAME
  35. * CTEST_CONTINUOUS_DURATION
  36. * CTEST_CONTINUOUS_MINIMUM_INTERVAL
  37. * CTEST_CVS_CHECKOUT
  38. * CTEST_CVS_COMMAND
  39. * CTEST_UPDATE_COMMAND
  40. * CTEST_DASHBOARD_ROOT
  41. * CTEST_ENVIRONMENT
  42. * CTEST_INITIAL_CACHE
  43. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
  44. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
  45. *
  46. * In addition the following variables can be used. The number can be 1-10.
  47. * CTEST_EXTRA_UPDATES_1
  48. * CTEST_EXTRA_UPDATES_2
  49. * ...
  50. * CTEST_EXTRA_UPDATES_10
  51. *
  52. * CTest script can use the following arguments CTest provides:
  53. * CTEST_SCRIPT_ARG
  54. * CTEST_SCRIPT_DIRECTORY
  55. * CTEST_SCRIPT_NAME
  56. *
  57. */
  58. class cmCTestScriptHandler : public cmCTestGenericHandler
  59. {
  60. public:
  61. cmTypeMacro(cmCTestScriptHandler, cmCTestGenericHandler);
  62. /**
  63. * Add a script to run, and if is should run in the current process
  64. */
  65. void AddConfigurationScript(const char *, bool pscope);
  66. /**
  67. * Run a dashboard using a specified confiuration script
  68. */
  69. int ProcessHandler();
  70. /*
  71. * Run a script
  72. */
  73. static bool RunScript(cmCTest* ctest, const char *script, bool InProcess);
  74. int RunCurrentScript();
  75. /*
  76. * Empty Binary Directory
  77. */
  78. static bool EmptyBinaryDirectory(const char *dir);
  79. /*
  80. * Some elapsed time handling functions
  81. */
  82. static void SleepInSeconds(unsigned int secondsToWait);
  83. void UpdateElapsedTime();
  84. /**
  85. * Return the time remaianing that the script is allowed to run in
  86. * seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
  87. * not been set it returns 1e7 seconds
  88. */
  89. double GetRemainingTimeAllowed();
  90. cmCTestScriptHandler();
  91. ~cmCTestScriptHandler();
  92. void Initialize();
  93. void CreateCMake();
  94. void GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const;
  95. private:
  96. // reads in a script
  97. int ReadInScript(const std::string& total_script_arg);
  98. int ExecuteScript(const std::string& total_script_arg);
  99. // extract vars from the script to set ivars
  100. int ExtractVariables();
  101. // perform a CVS checkout of the source dir
  102. int CheckOutSourceDir();
  103. // perform any extra cvs updates that were requested
  104. int PerformExtraUpdates();
  105. // backup and restore dirs
  106. int BackupDirectories();
  107. void RestoreBackupDirectories();
  108. int RunConfigurationScript(const std::string& script, bool pscope);
  109. int RunConfigurationDashboard();
  110. // Add ctest command
  111. void AddCTestCommand(cmCTestCommand* command);
  112. std::vector<cmStdString> ConfigurationScripts;
  113. std::vector<bool> ScriptProcessScope;
  114. bool Backup;
  115. bool EmptyBinDir;
  116. bool EmptyBinDirOnce;
  117. cmStdString SourceDir;
  118. cmStdString BinaryDir;
  119. cmStdString BackupSourceDir;
  120. cmStdString BackupBinaryDir;
  121. cmStdString CTestRoot;
  122. cmStdString CVSCheckOut;
  123. cmStdString CTestCmd;
  124. cmStdString UpdateCmd;
  125. cmStdString CTestEnv;
  126. cmStdString InitCache;
  127. cmStdString CMakeCmd;
  128. cmStdString CMOutFile;
  129. std::vector<cmStdString> ExtraUpdates;
  130. double MinimumInterval;
  131. double ContinuousDuration;
  132. // what time in seconds did this script start running
  133. double ScriptStartTime;
  134. cmMakefile *Makefile;
  135. cmLocalGenerator *LocalGenerator;
  136. cmGlobalGenerator *GlobalGenerator;
  137. cmake *CMake;
  138. };
  139. #endif