cmCTestLaunch.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <set>
  6. #include <string>
  7. #include <vector>
  8. #include "cmsys/RegularExpression.hxx"
  9. class cmXMLElement;
  10. /** \class cmCTestLaunch
  11. * \brief Launcher for make rules to report results for ctest
  12. *
  13. * This implements the 'ctest --launch' tool.
  14. */
  15. class cmCTestLaunch
  16. {
  17. public:
  18. /** Entry point from ctest executable main(). */
  19. static int Main(int argc, const char* const argv[]);
  20. private:
  21. // Initialize the launcher from its command line.
  22. cmCTestLaunch(int argc, const char* const* argv);
  23. ~cmCTestLaunch();
  24. cmCTestLaunch(const cmCTestLaunch&) = delete;
  25. cmCTestLaunch& operator=(const cmCTestLaunch&) = delete;
  26. // Run the real command.
  27. int Run();
  28. void RunChild();
  29. // Methods to check the result of the real command.
  30. bool IsError() const;
  31. bool CheckResults();
  32. // Launcher options specified before the real command.
  33. std::string OptionOutput;
  34. std::string OptionSource;
  35. std::string OptionLanguage;
  36. std::string OptionTargetName;
  37. std::string OptionTargetType;
  38. std::string OptionBuildDir;
  39. std::string OptionFilterPrefix;
  40. bool ParseArguments(int argc, const char* const* argv);
  41. // The real command line appearing after launcher arguments.
  42. int RealArgC;
  43. const char* const* RealArgV;
  44. std::string CWD;
  45. // The real command line after response file expansion.
  46. std::vector<std::string> RealArgs;
  47. void HandleRealArg(const char* arg);
  48. // A hash of the real command line is unique and unlikely to collide.
  49. std::string LogHash;
  50. void ComputeFileNames();
  51. bool Passthru;
  52. struct cmsysProcess_s* Process;
  53. int ExitCode;
  54. // Temporary log files for stdout and stderr of real command.
  55. std::string LogDir;
  56. std::string LogOut;
  57. std::string LogErr;
  58. bool HaveOut;
  59. bool HaveErr;
  60. // Labels associated with the build rule.
  61. std::set<std::string> Labels;
  62. void LoadLabels();
  63. bool SourceMatches(std::string const& lhs, std::string const& rhs);
  64. // Regular expressions to match warnings and their exceptions.
  65. bool ScrapeRulesLoaded;
  66. std::vector<cmsys::RegularExpression> RegexWarning;
  67. std::vector<cmsys::RegularExpression> RegexWarningSuppress;
  68. void LoadScrapeRules();
  69. void LoadScrapeRules(const char* purpose,
  70. std::vector<cmsys::RegularExpression>& regexps);
  71. bool ScrapeLog(std::string const& fname);
  72. bool Match(std::string const& line,
  73. std::vector<cmsys::RegularExpression>& regexps);
  74. bool MatchesFilterPrefix(std::string const& line) const;
  75. // Methods to generate the xml fragment.
  76. void WriteXML();
  77. void WriteXMLAction(cmXMLElement&);
  78. void WriteXMLCommand(cmXMLElement&);
  79. void WriteXMLResult(cmXMLElement&);
  80. void WriteXMLLabels(cmXMLElement&);
  81. void DumpFileToXML(cmXMLElement&, const char* tag, std::string const& fname);
  82. // Configuration
  83. void LoadConfig();
  84. std::string SourceDir;
  85. };