cmCTestLaunchReporter.h 2.4 KB

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