cmCTestScriptHandler.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <memory>
  6. #include <string>
  7. #include <vector>
  8. #include "cmCTestGenericHandler.h"
  9. class cmCTest;
  10. class cmCTestCommand;
  11. class cmGlobalGenerator;
  12. class cmMakefile;
  13. class cmake;
  14. /** \class cmCTestScriptHandler
  15. * \brief A class that handles ctest -S invocations
  16. */
  17. class cmCTestScriptHandler : public cmCTestGenericHandler
  18. {
  19. public:
  20. using Superclass = cmCTestGenericHandler;
  21. /**
  22. * Add a script to run, and if is should run in the current process
  23. */
  24. void AddConfigurationScript(const std::string&, bool pscope);
  25. /**
  26. * Run a dashboard using a specified confiuration script
  27. */
  28. int ProcessHandler() override;
  29. /*
  30. * Run a script
  31. */
  32. static bool RunScript(cmCTest* ctest, cmMakefile* mf,
  33. const std::string& script, bool InProcess,
  34. int* returnValue);
  35. /*
  36. * Some elapsed time handling functions
  37. */
  38. void UpdateElapsedTime();
  39. cmCTestScriptHandler();
  40. cmCTestScriptHandler(const cmCTestScriptHandler&) = delete;
  41. const cmCTestScriptHandler& operator=(const cmCTestScriptHandler&) = delete;
  42. ~cmCTestScriptHandler() override;
  43. void Initialize(cmCTest* ctest) override;
  44. void CreateCMake();
  45. cmake* GetCMake() { return this->CMake.get(); }
  46. cmMakefile* GetMakefile() { return this->Makefile.get(); }
  47. private:
  48. // reads in a script
  49. int ReadInScript(const std::string& total_script_arg);
  50. int ExecuteScript(const std::string& total_script_arg);
  51. int RunConfigurationScript(const std::string& script, bool pscope);
  52. // Add ctest command
  53. void AddCTestCommand(std::string const& name,
  54. std::unique_ptr<cmCTestCommand> command);
  55. std::vector<std::string> ConfigurationScripts;
  56. std::vector<bool> ScriptProcessScope;
  57. std::unique_ptr<cmMakefile> Makefile;
  58. cmMakefile* ParentMakefile = nullptr;
  59. std::unique_ptr<cmGlobalGenerator> GlobalGenerator;
  60. std::unique_ptr<cmake> CMake;
  61. };