cmCTestLaunch.h 3.2 KB

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