cmCTestBuildHandler.h 3.9 KB

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