cmCTestLaunchReporter.h 2.5 KB

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