cmCTestLaunch.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 cmXMLWriter;
  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. // Run the real command.
  26. int Run();
  27. void RunChild();
  28. // Methods to check the result of the real command.
  29. bool IsError() const;
  30. bool CheckResults();
  31. // Launcher options specified before the real command.
  32. std::string OptionOutput;
  33. std::string OptionSource;
  34. std::string OptionLanguage;
  35. std::string OptionTargetName;
  36. std::string OptionTargetType;
  37. std::string OptionBuildDir;
  38. std::string OptionFilterPrefix;
  39. bool ParseArguments(int argc, const char* const* argv);
  40. // The real command line appearing after launcher arguments.
  41. int RealArgC;
  42. const char* const* RealArgV;
  43. std::string CWD;
  44. // The real command line after response file expansion.
  45. std::vector<std::string> RealArgs;
  46. void HandleRealArg(const char* arg);
  47. // A hash of the real command line is unique and unlikely to collide.
  48. std::string LogHash;
  49. void ComputeFileNames();
  50. bool Passthru;
  51. struct cmsysProcess_s* Process;
  52. int ExitCode;
  53. // Temporary log files for stdout and stderr of real command.
  54. std::string LogDir;
  55. std::string LogOut;
  56. std::string LogErr;
  57. bool HaveOut;
  58. bool HaveErr;
  59. // Labels associated with the build rule.
  60. std::set<std::string> Labels;
  61. void LoadLabels();
  62. bool SourceMatches(std::string const& lhs, std::string const& rhs);
  63. // Regular expressions to match warnings and their exceptions.
  64. bool ScrapeRulesLoaded;
  65. std::vector<cmsys::RegularExpression> RegexWarning;
  66. std::vector<cmsys::RegularExpression> RegexWarningSuppress;
  67. void LoadScrapeRules();
  68. void LoadScrapeRules(const char* purpose,
  69. std::vector<cmsys::RegularExpression>& regexps);
  70. bool ScrapeLog(std::string const& fname);
  71. bool Match(std::string const& line,
  72. std::vector<cmsys::RegularExpression>& regexps);
  73. bool MatchesFilterPrefix(std::string const& line) const;
  74. // Methods to generate the xml fragment.
  75. void WriteXML();
  76. void WriteXMLAction(cmXMLWriter& xml);
  77. void WriteXMLCommand(cmXMLWriter& xml);
  78. void WriteXMLResult(cmXMLWriter& xml);
  79. void WriteXMLLabels(cmXMLWriter& xml);
  80. void DumpFileToXML(cmXMLWriter& xml, std::string const& fname);
  81. // Configuration
  82. void LoadConfig();
  83. std::string SourceDir;
  84. };
  85. #endif