cmCTestScriptHandler.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_DASHBOARD_ROOT
  40. * CTEST_ENVIRONMENT
  41. * CTEST_INITIAL_CACHE
  42. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
  43. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
  44. *
  45. * In addition the following variables can be used. The number can be 1-10.
  46. * CTEST_EXTRA_UPDATES_1
  47. * CTEST_EXTRA_UPDATES_2
  48. * ...
  49. * CTEST_EXTRA_UPDATES_10
  50. *
  51. * CTest script can use the following arguments CTest provides:
  52. * CTEST_SCRIPT_ARG
  53. * CTEST_SCRIPT_DIRECTORY
  54. * CTEST_SCRIPT_NAME
  55. *
  56. */
  57. class cmCTestScriptHandler : public cmCTestGenericHandler
  58. {
  59. public:
  60. cmTypeMacro(cmCTestScriptHandler, cmCTestGenericHandler);
  61. /**
  62. * Add a script to run, and if is should run in the current process
  63. */
  64. void AddConfigurationScript(const char *, bool pscope);
  65. /**
  66. * Run a dashboard using a specified confiuration script
  67. */
  68. int ProcessHandler();
  69. /*
  70. * Run a script
  71. */
  72. static bool RunScript(cmCTest* ctest, const char *script, bool InProcess);
  73. int RunCurrentScript();
  74. /*
  75. * Empty Binary Directory
  76. */
  77. static bool EmptyBinaryDirectory(const char *dir);
  78. /*
  79. * Some elapsed time handling functions
  80. */
  81. static void SleepInSeconds(unsigned int secondsToWait);
  82. void UpdateElapsedTime();
  83. cmCTestScriptHandler();
  84. ~cmCTestScriptHandler();
  85. void Initialize();
  86. private:
  87. // reads in a script
  88. int ReadInScript(const std::string& total_script_arg);
  89. int ExecuteScript(const std::string& total_script_arg);
  90. // extract vars from the script to set ivars
  91. int ExtractVariables();
  92. // perform a CVS checkout of the source dir
  93. int CheckOutSourceDir();
  94. // perform any extra cvs updates that were requested
  95. int PerformExtraUpdates();
  96. // backup and restore dirs
  97. int BackupDirectories();
  98. void RestoreBackupDirectories();
  99. int RunConfigurationScript(const std::string& script, bool pscope);
  100. int RunConfigurationDashboard();
  101. // Add ctest command
  102. void AddCTestCommand(cmCTestCommand* command);
  103. std::vector<cmStdString> ConfigurationScripts;
  104. std::vector<bool> ScriptProcessScope;
  105. bool Backup;
  106. bool EmptyBinDir;
  107. bool EmptyBinDirOnce;
  108. cmStdString SourceDir;
  109. cmStdString BinaryDir;
  110. cmStdString BackupSourceDir;
  111. cmStdString BackupBinaryDir;
  112. cmStdString CTestRoot;
  113. cmStdString CVSCheckOut;
  114. cmStdString CTestCmd;
  115. cmStdString CVSCmd;
  116. cmStdString CTestEnv;
  117. cmStdString InitCache;
  118. cmStdString CMakeCmd;
  119. cmStdString CMOutFile;
  120. std::vector<cmStdString> ExtraUpdates;
  121. double MinimumInterval;
  122. double ContinuousDuration;
  123. // what time in seconds did this script start running
  124. double ScriptStartTime;
  125. cmMakefile *Makefile;
  126. cmLocalGenerator *LocalGenerator;
  127. cmGlobalGenerator *GlobalGenerator;
  128. cmake *CMake;
  129. };
  130. #endif