cmCTestScriptHandler.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 cmCTestScriptHandler
  22. * \brief A class that handles ctest -S invocations
  23. *
  24. * CTest script is controlled using several variables that script has to
  25. * specify and some optional ones. Required ones are:
  26. * CTEST_SOURCE_DIRECTORY - Source directory of the project
  27. * CTEST_BINARY_DIRECTORY - Binary directory of the project
  28. * CTEST_COMMAND - Testing commands
  29. *
  30. * Optional variables are:
  31. * CTEST_BACKUP_AND_RESTORE
  32. * CTEST_CMAKE_COMMAND
  33. * CTEST_CMAKE_OUTPUT_FILE_NAME
  34. * CTEST_CONTINUOUS_DURATION
  35. * CTEST_CONTINUOUS_MINIMUM_INTERVAL
  36. * CTEST_CVS_CHECKOUT
  37. * CTEST_CVS_COMMAND
  38. * CTEST_DASHBOARD_ROOT
  39. * CTEST_ENVIRONMENT
  40. * CTEST_INITIAL_CACHE
  41. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
  42. * CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
  43. *
  44. * In addition the follwing variables can be used. The number can be 1-10.
  45. * CTEST_EXTRA_UPDATES_1
  46. * CTEST_EXTRA_UPDATES_2
  47. * ...
  48. * CTEST_EXTRA_UPDATES_10
  49. *
  50. * CTest script can use the following arguments CTest provides:
  51. * CTEST_SCRIPT_ARG
  52. * CTEST_SCRIPT_DIRECTORY
  53. * CTEST_SCRIPT_NAME
  54. *
  55. */
  56. class cmCTestScriptHandler : public cmCTestGenericHandler
  57. {
  58. public:
  59. /**
  60. * Add a script to run
  61. */
  62. void AddConfigurationScript(const char *);
  63. /**
  64. * Run a dashboard using a specified confiuration script
  65. */
  66. int ProcessHandler();
  67. /*
  68. * Run a script
  69. */
  70. static bool RunScript(cmCTest* ctest, const char *script);
  71. int RunCurrentScript();
  72. /*
  73. * Empty Binary Directory
  74. */
  75. static bool EmptyBinaryDirectory(const char *dir);
  76. /*
  77. * Some elapsed time handling functions
  78. */
  79. static void SleepInSeconds(unsigned int secondsToWait);
  80. void UpdateElapsedTime();
  81. cmCTestScriptHandler();
  82. ~cmCTestScriptHandler();
  83. private:
  84. // reads in a script
  85. int ReadInScript(const std::string& total_script_arg);
  86. // extract vars from the script to set ivars
  87. int ExtractVariables();
  88. // perform a CVS checkout of the source dir
  89. int CheckOutSourceDir();
  90. // perform any extra cvs updates that were requested
  91. int PerformExtraUpdates();
  92. // backup and restore dirs
  93. int BackupDirectories();
  94. void RestoreBackupDirectories();
  95. int RunConfigurationScript(const std::string& script);
  96. int RunConfigurationDashboard();
  97. std::vector<cmStdString> m_ConfigurationScripts;
  98. bool m_Backup;
  99. bool m_EmptyBinDir;
  100. bool m_EmptyBinDirOnce;
  101. cmStdString m_SourceDir;
  102. cmStdString m_BinaryDir;
  103. cmStdString m_BackupSourceDir;
  104. cmStdString m_BackupBinaryDir;
  105. cmStdString m_CTestRoot;
  106. cmStdString m_CVSCheckOut;
  107. cmStdString m_CTestCmd;
  108. cmStdString m_CVSCmd;
  109. cmStdString m_CTestEnv;
  110. cmStdString m_InitCache;
  111. cmStdString m_CMakeCmd;
  112. cmStdString m_CMOutFile;
  113. std::vector<cmStdString> m_ExtraUpdates;
  114. double m_MinimumInterval;
  115. double m_ContinuousDuration;
  116. // what time in seconds did this script start running
  117. double m_ScriptStartTime;
  118. cmMakefile *m_Makefile;
  119. cmLocalGenerator *m_LocalGenerator;
  120. cmGlobalGenerator *m_GlobalGenerator;
  121. cmake *m_CMake;
  122. };
  123. #endif