cmCTestBuildHandler.h 4.1 KB

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