cmCTestLaunch.h 3.0 KB

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