cmCTestBuildHandler.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 cmCTestBuildHandler_h
  4. #define cmCTestBuildHandler_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmCTestGenericHandler.h"
  7. #include "cmProcessOutput.h"
  8. #include "cmsys/RegularExpression.hxx"
  9. #include <deque>
  10. #include <iosfwd>
  11. #include <stddef.h>
  12. #include <string>
  13. #include <vector>
  14. class cmMakefile;
  15. class cmXMLWriter;
  16. /** \class cmCTestBuildHandler
  17. * \brief A class that handles ctest -S invocations
  18. *
  19. */
  20. class cmCTestBuildHandler : public cmCTestGenericHandler
  21. {
  22. public:
  23. typedef cmCTestGenericHandler Superclass;
  24. typedef cmProcessOutput::Encoding Encoding;
  25. /*
  26. * The main entry point for this class
  27. */
  28. int ProcessHandler() CM_OVERRIDE;
  29. cmCTestBuildHandler();
  30. void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
  31. /**
  32. * Initialize handler
  33. */
  34. void Initialize() CM_OVERRIDE;
  35. int GetTotalErrors() { return this->TotalErrors; }
  36. int GetTotalWarnings() { return this->TotalWarnings; }
  37. private:
  38. std::string GetMakeCommand();
  39. //! Run command specialized for make and configure. Returns process status
  40. // and retVal is return value or exception.
  41. int RunMakeCommand(const char* command, int* retVal, const char* dir,
  42. int timeout, std::ostream& ofs,
  43. Encoding encoding = cmProcessOutput::Auto);
  44. enum
  45. {
  46. b_REGULAR_LINE,
  47. b_WARNING_LINE,
  48. b_ERROR_LINE
  49. };
  50. class cmCTestCompileErrorWarningRex
  51. {
  52. public:
  53. cmCTestCompileErrorWarningRex() {}
  54. int FileIndex;
  55. int LineIndex;
  56. cmsys::RegularExpression RegularExpression;
  57. };
  58. struct cmCTestBuildErrorWarning
  59. {
  60. bool Error;
  61. int LogLine;
  62. std::string Text;
  63. std::string SourceFile;
  64. std::string SourceFileTail;
  65. int LineNumber;
  66. std::string PreContext;
  67. std::string PostContext;
  68. };
  69. // generate the XML output
  70. void GenerateXMLHeader(cmXMLWriter& xml);
  71. void GenerateXMLLaunched(cmXMLWriter& xml);
  72. void GenerateXMLLogScraped(cmXMLWriter& xml);
  73. void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
  74. bool IsLaunchedErrorFile(const char* fname);
  75. bool IsLaunchedWarningFile(const char* fname);
  76. std::string StartBuild;
  77. std::string EndBuild;
  78. double StartBuildTime;
  79. double EndBuildTime;
  80. std::vector<std::string> CustomErrorMatches;
  81. std::vector<std::string> CustomErrorExceptions;
  82. std::vector<std::string> CustomWarningMatches;
  83. std::vector<std::string> CustomWarningExceptions;
  84. std::vector<std::string> ReallyCustomWarningMatches;
  85. std::vector<std::string> ReallyCustomWarningExceptions;
  86. std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
  87. std::vector<cmsys::RegularExpression> ErrorMatchRegex;
  88. std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
  89. std::vector<cmsys::RegularExpression> WarningMatchRegex;
  90. std::vector<cmsys::RegularExpression> WarningExceptionRegex;
  91. typedef std::deque<char> t_BuildProcessingQueueType;
  92. void ProcessBuffer(const char* data, size_t length, size_t& tick,
  93. size_t tick_len, std::ostream& ofs,
  94. t_BuildProcessingQueueType* queue);
  95. int ProcessSingleLine(const char* data);
  96. t_BuildProcessingQueueType BuildProcessingQueue;
  97. t_BuildProcessingQueueType BuildProcessingErrorQueue;
  98. size_t BuildOutputLogSize;
  99. std::vector<char> CurrentProcessingLine;
  100. std::string SimplifySourceDir;
  101. std::string SimplifyBuildDir;
  102. size_t OutputLineCounter;
  103. typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
  104. t_ErrorsAndWarningsVector ErrorsAndWarnings;
  105. t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
  106. size_t PostContextCount;
  107. size_t MaxPreContext;
  108. size_t MaxPostContext;
  109. std::deque<std::string> PreContext;
  110. int TotalErrors;
  111. int TotalWarnings;
  112. char LastTickChar;
  113. bool ErrorQuotaReached;
  114. bool WarningQuotaReached;
  115. int MaxErrors;
  116. int MaxWarnings;
  117. bool UseCTestLaunch;
  118. std::string CTestLaunchDir;
  119. class LaunchHelper;
  120. friend class LaunchHelper;
  121. class FragmentCompare;
  122. };
  123. #endif