cmCTestLaunch.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 cmCTestLaunch
  15. * \brief Launcher for make rules to report results for ctest
  16. *
  17. * This implements the 'ctest --launch' tool.
  18. */
  19. class cmCTestLaunch
  20. {
  21. public:
  22. /** Entry point from ctest executable main(). */
  23. static int Main(int argc, const char* const argv[]);
  24. private:
  25. // Initialize the launcher from its command line.
  26. cmCTestLaunch(int argc, const char* const* argv);
  27. ~cmCTestLaunch();
  28. // Run the real command.
  29. int Run();
  30. void RunChild();
  31. // Methods to check the result of the real command.
  32. bool IsError() const;
  33. bool CheckResults();
  34. // Launcher options specified before the real command.
  35. std::string OptionOutput;
  36. std::string OptionSource;
  37. std::string OptionLanguage;
  38. std::string OptionTargetName;
  39. std::string OptionTargetType;
  40. std::string OptionBuildDir;
  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<cmStdString> Labels;
  63. void LoadLabels();
  64. bool SourceMatches(std::string const& lhs,
  65. std::string const& rhs);
  66. // Regular expressions to match warnings and their exceptions.
  67. bool ScrapeRulesLoaded;
  68. std::vector<cmsys::RegularExpression> RegexWarning;
  69. std::vector<cmsys::RegularExpression> RegexWarningSuppress;
  70. void LoadScrapeRules();
  71. void LoadScrapeRules(const char* purpose,
  72. std::vector<cmsys::RegularExpression>& regexps);
  73. bool ScrapeLog(std::string const& fname);
  74. bool Match(std::string const& line,
  75. std::vector<cmsys::RegularExpression>& regexps);
  76. // Methods to generate the xml fragment.
  77. void WriteXML();
  78. void WriteXMLAction(std::ostream& fxml);
  79. void WriteXMLCommand(std::ostream& fxml);
  80. void WriteXMLResult(std::ostream& fxml);
  81. void WriteXMLLabels(std::ostream& fxml);
  82. void DumpFileToXML(std::ostream& fxml, std::string const& fname);
  83. // Configuration
  84. void LoadConfig();
  85. std::string SourceDir;
  86. };
  87. #endif