cmCTestLaunchReporter.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst 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 "cmUVProcessChain.h"
  9. namespace cmsys {
  10. class RegularExpression;
  11. }
  12. class cmXMLElement;
  13. /** \class cmCTestLaunchReporter
  14. * \brief Generate CTest XML output for the 'ctest --launch' tool.
  15. */
  16. class cmCTestLaunchReporter
  17. {
  18. public:
  19. // Initialize the launcher from its command line.
  20. cmCTestLaunchReporter();
  21. ~cmCTestLaunchReporter();
  22. cmCTestLaunchReporter(cmCTestLaunchReporter const&) = delete;
  23. cmCTestLaunchReporter& operator=(cmCTestLaunchReporter const&) = delete;
  24. // Methods to check the result of the real command.
  25. bool IsError() const;
  26. // Launcher options specified before the real command.
  27. std::string OptionOutput;
  28. std::string OptionSource;
  29. std::string OptionLanguage;
  30. std::string OptionTargetLabels;
  31. std::string OptionTargetName;
  32. std::string OptionTargetType;
  33. std::string OptionCurrentBuildDir;
  34. std::string OptionBuildDir;
  35. std::string OptionFilterPrefix;
  36. std::string OptionCommandType;
  37. std::string OptionRole;
  38. std::string OptionConfig;
  39. std::string OptionObjectDir;
  40. // The real command line appearing after launcher arguments.
  41. std::string CWD;
  42. // The real command line after response file expansion.
  43. std::vector<std::string> RealArgs;
  44. // A hash of the real command line is unique and unlikely to collide.
  45. std::string LogHash;
  46. void ComputeFileNames();
  47. bool Passthru;
  48. cmUVProcessChain::Status Status;
  49. int ExitCode;
  50. // Temporary log files for stdout and stderr of real command.
  51. std::string LogDir;
  52. std::string LogOut;
  53. std::string LogErr;
  54. // Labels associated with the build rule.
  55. std::set<std::string> Labels;
  56. void LoadLabels();
  57. bool SourceMatches(std::string const& lhs, std::string const& rhs);
  58. // Regular expressions to match warnings and their exceptions.
  59. std::vector<cmsys::RegularExpression> RegexWarning;
  60. std::vector<cmsys::RegularExpression> RegexWarningSuppress;
  61. bool Match(std::string const& line,
  62. std::vector<cmsys::RegularExpression>& regexps);
  63. bool MatchesFilterPrefix(std::string const& line) const;
  64. // Methods to generate the xml fragment.
  65. void WriteXML();
  66. void WriteXMLAction(cmXMLElement&) const;
  67. void WriteXMLCommand(cmXMLElement&);
  68. void WriteXMLResult(cmXMLElement&);
  69. void WriteXMLLabels(cmXMLElement&);
  70. void DumpFileToXML(cmXMLElement&, char const* tag, std::string const& fname);
  71. // Configuration
  72. std::string SourceDir;
  73. };