cmCTestBuildHandler.cxx 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCTestBuildHandler.h"
  4. #include "cmAlgorithms.h"
  5. #include "cmCTest.h"
  6. #include "cmDuration.h"
  7. #include "cmFileTimeComparison.h"
  8. #include "cmGeneratedFileStream.h"
  9. #include "cmMakefile.h"
  10. #include "cmProcessOutput.h"
  11. #include "cmSystemTools.h"
  12. #include "cmXMLWriter.h"
  13. #include "cmsys/Directory.hxx"
  14. #include "cmsys/FStream.hxx"
  15. #include "cmsys/Process.h"
  16. #include <set>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <utility>
  20. static const char* cmCTestErrorMatches[] = {
  21. "^[Bb]us [Ee]rror",
  22. "^[Ss]egmentation [Vv]iolation",
  23. "^[Ss]egmentation [Ff]ault",
  24. ":.*[Pp]ermission [Dd]enied",
  25. "([^ :]+):([0-9]+): ([^ \\t])",
  26. "([^:]+): error[ \\t]*[0-9]+[ \\t]*:",
  27. "^Error ([0-9]+):",
  28. "^Fatal",
  29. "^Error: ",
  30. "^Error ",
  31. "[0-9] ERROR: ",
  32. "^\"[^\"]+\", line [0-9]+: [^Ww]",
  33. "^cc[^C]*CC: ERROR File = ([^,]+), Line = ([0-9]+)",
  34. "^ld([^:])*:([ \\t])*ERROR([^:])*:",
  35. "^ild:([ \\t])*\\(undefined symbol\\)",
  36. "([^ :]+) : (error|fatal error|catastrophic error)",
  37. "([^:]+): (Error:|error|undefined reference|multiply defined)",
  38. "([^:]+)\\(([^\\)]+)\\) ?: (error|fatal error|catastrophic error)",
  39. "^fatal error C[0-9]+:",
  40. ": syntax error ",
  41. "^collect2: ld returned 1 exit status",
  42. "ld terminated with signal",
  43. "Unsatisfied symbol",
  44. "^Unresolved:",
  45. "Undefined symbol",
  46. "^Undefined[ \\t]+first referenced",
  47. "^CMake Error.*:",
  48. ":[ \\t]cannot find",
  49. ":[ \\t]can't find",
  50. ": \\*\\*\\* No rule to make target [`'].*\\'. Stop",
  51. ": \\*\\*\\* No targets specified and no makefile found",
  52. ": Invalid loader fixup for symbol",
  53. ": Invalid fixups exist",
  54. ": Can't find library for",
  55. ": internal link edit command failed",
  56. ": Unrecognized option [`'].*\\'",
  57. "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([^WI]\\)",
  58. "ld: 0706-006 Cannot find or open library file: -l ",
  59. "ild: \\(argument error\\) can't find library argument ::",
  60. "^could not be found and will not be loaded.",
  61. "s:616 string too big",
  62. "make: Fatal error: ",
  63. "ld: 0711-993 Error occurred while writing to the output file:",
  64. "ld: fatal: ",
  65. "final link failed:",
  66. "make: \\*\\*\\*.*Error",
  67. "make\\[.*\\]: \\*\\*\\*.*Error",
  68. "\\*\\*\\* Error code",
  69. "nternal error:",
  70. "Makefile:[0-9]+: \\*\\*\\* .* Stop\\.",
  71. ": No such file or directory",
  72. ": Invalid argument",
  73. "^The project cannot be built\\.",
  74. "^\\[ERROR\\]",
  75. "^Command .* failed with exit code",
  76. nullptr
  77. };
  78. static const char* cmCTestErrorExceptions[] = {
  79. "instantiated from ",
  80. "candidates are:",
  81. ": warning",
  82. ": \\(Warning\\)",
  83. ": note",
  84. "Note:",
  85. "makefile:",
  86. "Makefile:",
  87. ":[ \\t]+Where:",
  88. "([^ :]+):([0-9]+): Warning",
  89. "------ Build started: .* ------",
  90. nullptr
  91. };
  92. static const char* cmCTestWarningMatches[] = {
  93. "([^ :]+):([0-9]+): warning:",
  94. "([^ :]+):([0-9]+): note:",
  95. "^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)",
  96. "^ld([^:])*:([ \\t])*WARNING([^:])*:",
  97. "([^:]+): warning ([0-9]+):",
  98. "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)",
  99. "([^:]+): warning[ \\t]*[0-9]+[ \\t]*:",
  100. "^(Warning|Warnung) ([0-9]+):",
  101. "^(Warning|Warnung)[ :]",
  102. "WARNING: ",
  103. "([^ :]+) : warning",
  104. "([^:]+): warning",
  105. "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([WI]\\)",
  106. "^cxx: Warning:",
  107. ".*file: .* has no symbols",
  108. "([^ :]+):([0-9]+): (Warning|Warnung)",
  109. "\\([0-9]*\\): remark #[0-9]*",
  110. "\".*\", line [0-9]+: remark\\([0-9]*\\):",
  111. "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*",
  112. "^CMake Warning.*:",
  113. "^\\[WARNING\\]",
  114. nullptr
  115. };
  116. static const char* cmCTestWarningExceptions[] = {
  117. "/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
  118. "/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
  119. "/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
  120. "WARNING 84 :",
  121. "WARNING 47 :",
  122. "makefile:",
  123. "Makefile:",
  124. "warning: Clock skew detected. Your build may be incomplete.",
  125. "/usr/openwin/include/GL/[^:]+:",
  126. "bind_at_load",
  127. "XrmQGetResource",
  128. "IceFlush",
  129. "warning LNK4089: all references to [^ \\t]+ discarded by .OPT:REF",
  130. "ld32: WARNING 85: definition of dataKey in",
  131. "cc: warning 422: Unknown option \"\\+b",
  132. "_with_warning_C",
  133. nullptr
  134. };
  135. struct cmCTestBuildCompileErrorWarningRex
  136. {
  137. const char* RegularExpressionString;
  138. int FileIndex;
  139. int LineIndex;
  140. };
  141. static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = {
  142. { "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
  143. { "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
  144. { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
  145. { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
  146. { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
  147. { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
  148. { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
  149. { nullptr, 0, 0 }
  150. };
  151. cmCTestBuildHandler::cmCTestBuildHandler()
  152. {
  153. this->MaxPreContext = 10;
  154. this->MaxPostContext = 10;
  155. this->MaxErrors = 50;
  156. this->MaxWarnings = 50;
  157. this->LastErrorOrWarning = this->ErrorsAndWarnings.end();
  158. this->UseCTestLaunch = false;
  159. }
  160. void cmCTestBuildHandler::Initialize()
  161. {
  162. this->Superclass::Initialize();
  163. this->StartBuild.clear();
  164. this->EndBuild.clear();
  165. this->CustomErrorMatches.clear();
  166. this->CustomErrorExceptions.clear();
  167. this->CustomWarningMatches.clear();
  168. this->CustomWarningExceptions.clear();
  169. this->ReallyCustomWarningMatches.clear();
  170. this->ReallyCustomWarningExceptions.clear();
  171. this->ErrorWarningFileLineRegex.clear();
  172. this->ErrorMatchRegex.clear();
  173. this->ErrorExceptionRegex.clear();
  174. this->WarningMatchRegex.clear();
  175. this->WarningExceptionRegex.clear();
  176. this->BuildProcessingQueue.clear();
  177. this->BuildProcessingErrorQueue.clear();
  178. this->BuildOutputLogSize = 0;
  179. this->CurrentProcessingLine.clear();
  180. this->SimplifySourceDir.clear();
  181. this->SimplifyBuildDir.clear();
  182. this->OutputLineCounter = 0;
  183. this->ErrorsAndWarnings.clear();
  184. this->LastErrorOrWarning = this->ErrorsAndWarnings.end();
  185. this->PostContextCount = 0;
  186. this->MaxPreContext = 10;
  187. this->MaxPostContext = 10;
  188. this->PreContext.clear();
  189. this->TotalErrors = 0;
  190. this->TotalWarnings = 0;
  191. this->LastTickChar = 0;
  192. this->ErrorQuotaReached = false;
  193. this->WarningQuotaReached = false;
  194. this->MaxErrors = 50;
  195. this->MaxWarnings = 50;
  196. this->UseCTestLaunch = false;
  197. }
  198. void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf)
  199. {
  200. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH",
  201. this->CustomErrorMatches);
  202. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION",
  203. this->CustomErrorExceptions);
  204. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH",
  205. this->CustomWarningMatches);
  206. this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION",
  207. this->CustomWarningExceptions);
  208. this->CTest->PopulateCustomInteger(
  209. mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", this->MaxErrors);
  210. this->CTest->PopulateCustomInteger(
  211. mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings);
  212. int n = -1;
  213. this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n);
  214. if (n != -1) {
  215. this->MaxPreContext = static_cast<size_t>(n);
  216. }
  217. n = -1;
  218. this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n);
  219. if (n != -1) {
  220. this->MaxPostContext = static_cast<size_t>(n);
  221. }
  222. // Record the user-specified custom warning rules.
  223. if (const char* customWarningMatchers =
  224. mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) {
  225. cmSystemTools::ExpandListArgument(customWarningMatchers,
  226. this->ReallyCustomWarningMatches);
  227. }
  228. if (const char* customWarningExceptions =
  229. mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
  230. cmSystemTools::ExpandListArgument(customWarningExceptions,
  231. this->ReallyCustomWarningExceptions);
  232. }
  233. }
  234. std::string cmCTestBuildHandler::GetMakeCommand()
  235. {
  236. std::string makeCommand = this->CTest->GetCTestConfiguration("MakeCommand");
  237. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  238. "MakeCommand:" << makeCommand << "\n", this->Quiet);
  239. std::string configType = this->CTest->GetConfigType();
  240. if (configType.empty()) {
  241. configType =
  242. this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
  243. }
  244. if (configType.empty()) {
  245. configType = "Release";
  246. }
  247. cmSystemTools::ReplaceString(makeCommand, "${CTEST_CONFIGURATION_TYPE}",
  248. configType.c_str());
  249. return makeCommand;
  250. }
  251. // clearly it would be nice if this were broken up into a few smaller
  252. // functions and commented...
  253. int cmCTestBuildHandler::ProcessHandler()
  254. {
  255. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl,
  256. this->Quiet);
  257. // do we have time for this
  258. if (this->CTest->GetRemainingTimeAllowed() < std::chrono::minutes(2)) {
  259. return 0;
  260. }
  261. int entry;
  262. for (entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString;
  263. ++entry) {
  264. cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
  265. if (r.RegularExpression.compile(
  266. cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
  267. r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
  268. r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
  269. this->ErrorWarningFileLineRegex.push_back(std::move(r));
  270. } else {
  271. cmCTestLog(
  272. this->CTest, ERROR_MESSAGE,
  273. "Problem Compiling regular expression: "
  274. << cmCTestWarningErrorFileLine[entry].RegularExpressionString
  275. << std::endl);
  276. }
  277. }
  278. // Determine build command and build directory
  279. std::string makeCommand = this->GetMakeCommand();
  280. if (makeCommand.empty()) {
  281. cmCTestLog(this->CTest, ERROR_MESSAGE,
  282. "Cannot find MakeCommand key in the DartConfiguration.tcl"
  283. << std::endl);
  284. return -1;
  285. }
  286. const std::string& buildDirectory =
  287. this->CTest->GetCTestConfiguration("BuildDirectory");
  288. if (buildDirectory.empty()) {
  289. cmCTestLog(this->CTest, ERROR_MESSAGE,
  290. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  291. << std::endl);
  292. return -1;
  293. }
  294. std::string const& useLaunchers =
  295. this->CTest->GetCTestConfiguration("UseLaunchers");
  296. this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers.c_str());
  297. // Create a last build log
  298. cmGeneratedFileStream ofs;
  299. auto elapsed_time_start = std::chrono::steady_clock::now();
  300. if (!this->StartLogFile("Build", ofs)) {
  301. cmCTestLog(this->CTest, ERROR_MESSAGE,
  302. "Cannot create build log file" << std::endl);
  303. }
  304. // Create lists of regular expression strings for errors, error exceptions,
  305. // warnings and warning exceptions.
  306. std::vector<std::string>::size_type cc;
  307. for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
  308. this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
  309. }
  310. for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
  311. this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
  312. }
  313. for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
  314. this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
  315. }
  316. for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
  317. this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
  318. }
  319. // Pre-compile regular expressions objects for all regular expressions
  320. #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
  321. regexes.clear(); \
  322. cmCTestOptionalLog(this->CTest, DEBUG, \
  323. this << "Add " #regexes << std::endl, this->Quiet); \
  324. for (std::string const& s : (strings)) { \
  325. cmCTestOptionalLog(this->CTest, DEBUG, \
  326. "Add " #strings ": " << s << std::endl, this->Quiet); \
  327. (regexes).push_back(s.c_str()); \
  328. }
  329. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
  330. this->ErrorMatchRegex);
  331. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
  332. this->ErrorExceptionRegex);
  333. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
  334. this->WarningMatchRegex);
  335. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
  336. this->WarningExceptionRegex);
  337. // Determine source and binary tree substitutions to simplify the output.
  338. this->SimplifySourceDir.clear();
  339. this->SimplifyBuildDir.clear();
  340. if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
  341. std::string srcdir =
  342. this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
  343. std::string srcdirrep;
  344. for (cc = srcdir.size() - 2; cc > 0; cc--) {
  345. if (srcdir[cc] == '/') {
  346. srcdirrep = srcdir.c_str() + cc;
  347. srcdirrep = "/..." + srcdirrep;
  348. srcdir = srcdir.substr(0, cc + 1);
  349. break;
  350. }
  351. }
  352. this->SimplifySourceDir = srcdir;
  353. }
  354. if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
  355. std::string bindir =
  356. this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
  357. std::string bindirrep;
  358. for (cc = bindir.size() - 2; cc > 0; cc--) {
  359. if (bindir[cc] == '/') {
  360. bindirrep = bindir.c_str() + cc;
  361. bindirrep = "/..." + bindirrep;
  362. bindir = bindir.substr(0, cc + 1);
  363. break;
  364. }
  365. }
  366. this->SimplifyBuildDir = bindir;
  367. }
  368. // Ok, let's do the build
  369. // Remember start build time
  370. this->StartBuild = this->CTest->CurrentTime();
  371. this->StartBuildTime = std::chrono::system_clock::now();
  372. int retVal = 0;
  373. int res = cmsysProcess_State_Exited;
  374. if (!this->CTest->GetShowOnly()) {
  375. res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
  376. buildDirectory.c_str(), 0, ofs);
  377. } else {
  378. cmCTestOptionalLog(this->CTest, DEBUG,
  379. "Build with command: " << makeCommand << std::endl,
  380. this->Quiet);
  381. }
  382. // Remember end build time and calculate elapsed time
  383. this->EndBuild = this->CTest->CurrentTime();
  384. this->EndBuildTime = std::chrono::system_clock::now();
  385. auto elapsed_build_time =
  386. std::chrono::steady_clock::now() - elapsed_time_start;
  387. // Cleanups strings in the errors and warnings list.
  388. if (!this->SimplifySourceDir.empty()) {
  389. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  390. cmSystemTools::ReplaceString(evit.Text, this->SimplifySourceDir.c_str(),
  391. "/.../");
  392. cmSystemTools::ReplaceString(evit.PreContext,
  393. this->SimplifySourceDir.c_str(), "/.../");
  394. cmSystemTools::ReplaceString(evit.PostContext,
  395. this->SimplifySourceDir.c_str(), "/.../");
  396. }
  397. }
  398. if (!this->SimplifyBuildDir.empty()) {
  399. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  400. cmSystemTools::ReplaceString(evit.Text, this->SimplifyBuildDir.c_str(),
  401. "/.../");
  402. cmSystemTools::ReplaceString(evit.PreContext,
  403. this->SimplifyBuildDir.c_str(), "/.../");
  404. cmSystemTools::ReplaceString(evit.PostContext,
  405. this->SimplifyBuildDir.c_str(), "/.../");
  406. }
  407. }
  408. // Generate XML output
  409. cmGeneratedFileStream xofs;
  410. if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
  411. cmCTestLog(this->CTest, ERROR_MESSAGE,
  412. "Cannot create build XML file" << std::endl);
  413. return -1;
  414. }
  415. cmXMLWriter xml(xofs);
  416. this->GenerateXMLHeader(xml);
  417. if (this->UseCTestLaunch) {
  418. this->GenerateXMLLaunched(xml);
  419. } else {
  420. this->GenerateXMLLogScraped(xml);
  421. }
  422. this->GenerateXMLFooter(xml, elapsed_build_time);
  423. if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
  424. cmCTestLog(this->CTest, ERROR_MESSAGE,
  425. "Error(s) when building project" << std::endl);
  426. }
  427. // Display message about number of errors and warnings
  428. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  429. " " << this->TotalErrors
  430. << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
  431. << " Compiler errors" << std::endl);
  432. cmCTestLog(
  433. this->CTest, HANDLER_OUTPUT,
  434. " " << this->TotalWarnings
  435. << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
  436. << " Compiler warnings" << std::endl);
  437. return retVal;
  438. }
  439. void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
  440. {
  441. this->CTest->StartXML(xml, this->AppendXML);
  442. this->CTest->GenerateSubprojectsOutput(xml);
  443. xml.StartElement("Build");
  444. xml.Element("StartDateTime", this->StartBuild);
  445. xml.Element("StartBuildTime", this->StartBuildTime);
  446. xml.Element("BuildCommand", this->GetMakeCommand());
  447. }
  448. class cmCTestBuildHandler::FragmentCompare
  449. {
  450. public:
  451. FragmentCompare(cmFileTimeComparison* ftc)
  452. : FTC(ftc)
  453. {
  454. }
  455. FragmentCompare()
  456. : FTC(nullptr)
  457. {
  458. }
  459. bool operator()(std::string const& l, std::string const& r) const
  460. {
  461. // Order files by modification time. Use lexicographic order
  462. // among files with the same time.
  463. int result;
  464. if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
  465. result != 0) {
  466. return result < 0;
  467. }
  468. return l < r;
  469. }
  470. private:
  471. cmFileTimeComparison* FTC;
  472. };
  473. void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
  474. {
  475. if (this->CTestLaunchDir.empty()) {
  476. return;
  477. }
  478. // Sort XML fragments in chronological order.
  479. cmFileTimeComparison ftc;
  480. FragmentCompare fragmentCompare(&ftc);
  481. typedef std::set<std::string, FragmentCompare> Fragments;
  482. Fragments fragments(fragmentCompare);
  483. // only report the first 50 warnings and first 50 errors
  484. int numErrorsAllowed = this->MaxErrors;
  485. int numWarningsAllowed = this->MaxWarnings;
  486. // Identify fragments on disk.
  487. cmsys::Directory launchDir;
  488. launchDir.Load(this->CTestLaunchDir);
  489. unsigned long n = launchDir.GetNumberOfFiles();
  490. for (unsigned long i = 0; i < n; ++i) {
  491. const char* fname = launchDir.GetFile(i);
  492. if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
  493. numErrorsAllowed--;
  494. fragments.insert(this->CTestLaunchDir + "/" + fname);
  495. ++this->TotalErrors;
  496. } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
  497. numWarningsAllowed--;
  498. fragments.insert(this->CTestLaunchDir + "/" + fname);
  499. ++this->TotalWarnings;
  500. }
  501. }
  502. // Copy the fragments into the final XML file.
  503. for (std::string const& f : fragments) {
  504. xml.FragmentFile(f.c_str());
  505. }
  506. }
  507. void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
  508. {
  509. std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
  510. std::vector<cmCTestBuildErrorWarning>::iterator it;
  511. // only report the first 50 warnings and first 50 errors
  512. int numErrorsAllowed = this->MaxErrors;
  513. int numWarningsAllowed = this->MaxWarnings;
  514. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  515. // make sure the source dir is in the correct case on windows
  516. // via a call to collapse full path.
  517. srcdir = cmSystemTools::CollapseFullPath(srcdir);
  518. srcdir += "/";
  519. for (it = ew.begin();
  520. it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
  521. cmCTestBuildErrorWarning* cm = &(*it);
  522. if ((cm->Error && numErrorsAllowed) ||
  523. (!cm->Error && numWarningsAllowed)) {
  524. if (cm->Error) {
  525. numErrorsAllowed--;
  526. } else {
  527. numWarningsAllowed--;
  528. }
  529. xml.StartElement(cm->Error ? "Error" : "Warning");
  530. xml.Element("BuildLogLine", cm->LogLine);
  531. xml.Element("Text", cm->Text);
  532. for (cmCTestCompileErrorWarningRex& rit :
  533. this->ErrorWarningFileLineRegex) {
  534. cmsys::RegularExpression* re = &rit.RegularExpression;
  535. if (re->find(cm->Text)) {
  536. cm->SourceFile = re->match(rit.FileIndex);
  537. // At this point we need to make this->SourceFile relative to
  538. // the source root of the project, so cvs links will work
  539. cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
  540. if (cm->SourceFile.find("/.../") != std::string::npos) {
  541. cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
  542. std::string::size_type p = cm->SourceFile.find('/');
  543. if (p != std::string::npos) {
  544. cm->SourceFile =
  545. cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
  546. }
  547. } else {
  548. // make sure it is a full path with the correct case
  549. cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
  550. cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
  551. }
  552. cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
  553. break;
  554. }
  555. }
  556. if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
  557. if (!cm->SourceFile.empty()) {
  558. xml.Element("SourceFile", cm->SourceFile);
  559. }
  560. if (!cm->SourceFileTail.empty()) {
  561. xml.Element("SourceFileTail", cm->SourceFileTail);
  562. }
  563. if (cm->LineNumber >= 0) {
  564. xml.Element("SourceLineNumber", cm->LineNumber);
  565. }
  566. }
  567. xml.Element("PreContext", cm->PreContext);
  568. xml.StartElement("PostContext");
  569. xml.Content(cm->PostContext);
  570. // is this the last warning or error, if so notify
  571. if ((cm->Error && !numErrorsAllowed) ||
  572. (!cm->Error && !numWarningsAllowed)) {
  573. xml.Content("\nThe maximum number of reported warnings or errors "
  574. "has been reached!!!\n");
  575. }
  576. xml.EndElement(); // PostContext
  577. xml.Element("RepeatCount", "0");
  578. xml.EndElement(); // "Error" / "Warning"
  579. }
  580. }
  581. }
  582. void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
  583. cmDuration elapsed_build_time)
  584. {
  585. xml.StartElement("Log");
  586. xml.Attribute("Encoding", "base64");
  587. xml.Attribute("Compression", "bin/gzip");
  588. xml.EndElement(); // Log
  589. xml.Element("EndDateTime", this->EndBuild);
  590. xml.Element("EndBuildTime", this->EndBuildTime);
  591. xml.Element(
  592. "ElapsedMinutes",
  593. std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
  594. .count());
  595. xml.EndElement(); // Build
  596. this->CTest->EndXML(xml);
  597. }
  598. bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
  599. {
  600. // error-{hash}.xml
  601. return (cmHasLiteralPrefix(fname, "error-") &&
  602. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  603. }
  604. bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
  605. {
  606. // warning-{hash}.xml
  607. return (cmHasLiteralPrefix(fname, "warning-") &&
  608. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  609. }
  610. //######################################################################
  611. //######################################################################
  612. //######################################################################
  613. //######################################################################
  614. class cmCTestBuildHandler::LaunchHelper
  615. {
  616. public:
  617. LaunchHelper(cmCTestBuildHandler* handler);
  618. ~LaunchHelper();
  619. private:
  620. cmCTestBuildHandler* Handler;
  621. cmCTest* CTest;
  622. void WriteLauncherConfig();
  623. void WriteScrapeMatchers(const char* purpose,
  624. std::vector<std::string> const& matchers);
  625. };
  626. cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
  627. : Handler(handler)
  628. , CTest(handler->CTest)
  629. {
  630. std::string tag = this->CTest->GetCurrentTag();
  631. if (tag.empty()) {
  632. // This is not for a dashboard submission, so there is no XML.
  633. // Skip enabling the launchers.
  634. this->Handler->UseCTestLaunch = false;
  635. } else {
  636. // Compute a directory in which to store launcher fragments.
  637. std::string& launchDir = this->Handler->CTestLaunchDir;
  638. launchDir = this->CTest->GetBinaryDir();
  639. launchDir += "/Testing/";
  640. launchDir += tag;
  641. launchDir += "/Build";
  642. // Clean out any existing launcher fragments.
  643. cmSystemTools::RemoveADirectory(launchDir);
  644. if (this->Handler->UseCTestLaunch) {
  645. // Enable launcher fragments.
  646. cmSystemTools::MakeDirectory(launchDir);
  647. this->WriteLauncherConfig();
  648. std::string launchEnv = "CTEST_LAUNCH_LOGS=";
  649. launchEnv += launchDir;
  650. cmSystemTools::PutEnv(launchEnv);
  651. }
  652. }
  653. // If not using launchers, make sure they passthru.
  654. if (!this->Handler->UseCTestLaunch) {
  655. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  656. }
  657. }
  658. cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
  659. {
  660. if (this->Handler->UseCTestLaunch) {
  661. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  662. }
  663. }
  664. void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
  665. {
  666. this->WriteScrapeMatchers("Warning",
  667. this->Handler->ReallyCustomWarningMatches);
  668. this->WriteScrapeMatchers("WarningSuppress",
  669. this->Handler->ReallyCustomWarningExceptions);
  670. // Give some testing configuration information to the launcher.
  671. std::string fname = this->Handler->CTestLaunchDir;
  672. fname += "/CTestLaunchConfig.cmake";
  673. cmGeneratedFileStream fout(fname.c_str());
  674. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  675. fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
  676. }
  677. void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
  678. const char* purpose, std::vector<std::string> const& matchers)
  679. {
  680. if (matchers.empty()) {
  681. return;
  682. }
  683. std::string fname = this->Handler->CTestLaunchDir;
  684. fname += "/Custom";
  685. fname += purpose;
  686. fname += ".txt";
  687. cmGeneratedFileStream fout(fname.c_str());
  688. for (std::string const& m : matchers) {
  689. fout << m << "\n";
  690. }
  691. }
  692. int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
  693. const char* dir, int timeout,
  694. std::ostream& ofs, Encoding encoding)
  695. {
  696. // First generate the command and arguments
  697. std::vector<std::string> args = cmSystemTools::ParseArguments(command);
  698. if (args.empty()) {
  699. return false;
  700. }
  701. std::vector<const char*> argv;
  702. argv.reserve(args.size() + 1);
  703. for (std::string const& arg : args) {
  704. argv.push_back(arg.c_str());
  705. }
  706. argv.push_back(nullptr);
  707. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  708. "Run command:", this->Quiet);
  709. for (char const* arg : argv) {
  710. if (!arg) {
  711. break;
  712. }
  713. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  714. " \"" << arg << "\"", this->Quiet);
  715. }
  716. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
  717. this->Quiet);
  718. // Optionally use make rule launchers to record errors and warnings.
  719. LaunchHelper launchHelper(this);
  720. static_cast<void>(launchHelper);
  721. // Now create process object
  722. cmsysProcess* cp = cmsysProcess_New();
  723. cmsysProcess_SetCommand(cp, &*argv.begin());
  724. cmsysProcess_SetWorkingDirectory(cp, dir);
  725. cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
  726. cmsysProcess_SetTimeout(cp, timeout);
  727. cmsysProcess_Execute(cp);
  728. // Initialize tick's
  729. std::string::size_type tick = 0;
  730. const std::string::size_type tick_len = 1024;
  731. char* data;
  732. int length;
  733. cmProcessOutput processOutput(encoding);
  734. std::string strdata;
  735. cmCTestOptionalLog(
  736. this->CTest, HANDLER_PROGRESS_OUTPUT,
  737. " Each symbol represents "
  738. << tick_len << " bytes of output." << std::endl
  739. << (this->UseCTestLaunch
  740. ? ""
  741. : " '!' represents an error and '*' a warning.\n")
  742. << " " << std::flush,
  743. this->Quiet);
  744. // Initialize building structures
  745. this->BuildProcessingQueue.clear();
  746. this->OutputLineCounter = 0;
  747. this->ErrorsAndWarnings.clear();
  748. this->TotalErrors = 0;
  749. this->TotalWarnings = 0;
  750. this->BuildOutputLogSize = 0;
  751. this->LastTickChar = '.';
  752. this->WarningQuotaReached = false;
  753. this->ErrorQuotaReached = false;
  754. // For every chunk of data
  755. int res;
  756. while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
  757. // Replace '\0' with '\n', since '\0' does not really make sense. This is
  758. // for Visual Studio output
  759. for (int cc = 0; cc < length; ++cc) {
  760. if (data[cc] == 0) {
  761. data[cc] = '\n';
  762. }
  763. }
  764. // Process the chunk of data
  765. if (res == cmsysProcess_Pipe_STDERR) {
  766. processOutput.DecodeText(data, length, strdata, 1);
  767. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  768. &this->BuildProcessingErrorQueue);
  769. } else {
  770. processOutput.DecodeText(data, length, strdata, 2);
  771. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  772. &this->BuildProcessingQueue);
  773. }
  774. }
  775. processOutput.DecodeText(std::string(), strdata, 1);
  776. if (!strdata.empty()) {
  777. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  778. &this->BuildProcessingErrorQueue);
  779. }
  780. processOutput.DecodeText(std::string(), strdata, 2);
  781. if (!strdata.empty()) {
  782. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  783. &this->BuildProcessingQueue);
  784. }
  785. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  786. &this->BuildProcessingQueue);
  787. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  788. &this->BuildProcessingErrorQueue);
  789. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  790. " Size of output: "
  791. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  792. << std::endl,
  793. this->Quiet);
  794. // Properly handle output of the build command
  795. cmsysProcess_WaitForExit(cp, nullptr);
  796. int result = cmsysProcess_GetState(cp);
  797. if (result == cmsysProcess_State_Exited) {
  798. if (retVal) {
  799. *retVal = cmsysProcess_GetExitValue(cp);
  800. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  801. "Command exited with the value: " << *retVal
  802. << std::endl,
  803. this->Quiet);
  804. // if a non zero return value
  805. if (*retVal) {
  806. // If there was an error running command, report that on the
  807. // dashboard.
  808. cmCTestBuildErrorWarning errorwarning;
  809. errorwarning.LogLine = 1;
  810. errorwarning.Text =
  811. "*** WARNING non-zero return value in ctest from: ";
  812. errorwarning.Text += argv[0];
  813. errorwarning.PreContext.clear();
  814. errorwarning.PostContext.clear();
  815. errorwarning.Error = false;
  816. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  817. this->TotalWarnings++;
  818. }
  819. }
  820. } else if (result == cmsysProcess_State_Exception) {
  821. if (retVal) {
  822. *retVal = cmsysProcess_GetExitException(cp);
  823. cmCTestOptionalLog(this->CTest, WARNING,
  824. "There was an exception: " << *retVal << std::endl,
  825. this->Quiet);
  826. }
  827. } else if (result == cmsysProcess_State_Expired) {
  828. cmCTestOptionalLog(this->CTest, WARNING,
  829. "There was a timeout" << std::endl, this->Quiet);
  830. } else if (result == cmsysProcess_State_Error) {
  831. // If there was an error running command, report that on the dashboard.
  832. cmCTestBuildErrorWarning errorwarning;
  833. errorwarning.LogLine = 1;
  834. errorwarning.Text = "*** ERROR executing: ";
  835. errorwarning.Text += cmsysProcess_GetErrorString(cp);
  836. errorwarning.PreContext.clear();
  837. errorwarning.PostContext.clear();
  838. errorwarning.Error = true;
  839. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  840. this->TotalErrors++;
  841. cmCTestLog(this->CTest, ERROR_MESSAGE,
  842. "There was an error: " << cmsysProcess_GetErrorString(cp)
  843. << std::endl);
  844. }
  845. cmsysProcess_Delete(cp);
  846. return result;
  847. }
  848. //######################################################################
  849. //######################################################################
  850. //######################################################################
  851. //######################################################################
  852. void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
  853. size_t& tick, size_t tick_len,
  854. std::ostream& ofs,
  855. t_BuildProcessingQueueType* queue)
  856. {
  857. const std::string::size_type tick_line_len = 50;
  858. const char* ptr;
  859. for (ptr = data; ptr < data + length; ptr++) {
  860. queue->push_back(*ptr);
  861. }
  862. this->BuildOutputLogSize += length;
  863. // until there are any lines left in the buffer
  864. while (true) {
  865. // Find the end of line
  866. t_BuildProcessingQueueType::iterator it;
  867. for (it = queue->begin(); it != queue->end(); ++it) {
  868. if (*it == '\n') {
  869. break;
  870. }
  871. }
  872. // Once certain number of errors or warnings reached, ignore future errors
  873. // or warnings.
  874. if (this->TotalWarnings >= this->MaxWarnings) {
  875. this->WarningQuotaReached = true;
  876. }
  877. if (this->TotalErrors >= this->MaxErrors) {
  878. this->ErrorQuotaReached = true;
  879. }
  880. // If the end of line was found
  881. if (it != queue->end()) {
  882. // Create a contiguous array for the line
  883. this->CurrentProcessingLine.clear();
  884. this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
  885. queue->begin(), it);
  886. this->CurrentProcessingLine.push_back(0);
  887. const char* line = &*this->CurrentProcessingLine.begin();
  888. // Process the line
  889. int lineType = this->ProcessSingleLine(line);
  890. // Erase the line from the queue
  891. queue->erase(queue->begin(), it + 1);
  892. // Depending on the line type, produce error or warning, or nothing
  893. cmCTestBuildErrorWarning errorwarning;
  894. bool found = false;
  895. switch (lineType) {
  896. case b_WARNING_LINE:
  897. this->LastTickChar = '*';
  898. errorwarning.Error = false;
  899. found = true;
  900. this->TotalWarnings++;
  901. break;
  902. case b_ERROR_LINE:
  903. this->LastTickChar = '!';
  904. errorwarning.Error = true;
  905. found = true;
  906. this->TotalErrors++;
  907. break;
  908. }
  909. if (found) {
  910. // This is an error or warning, so generate report
  911. errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
  912. errorwarning.Text = line;
  913. errorwarning.PreContext.clear();
  914. errorwarning.PostContext.clear();
  915. // Copy pre-context to report
  916. for (std::string const& pc : this->PreContext) {
  917. errorwarning.PreContext += pc + "\n";
  918. }
  919. this->PreContext.clear();
  920. // Store report
  921. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  922. this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
  923. this->PostContextCount = 0;
  924. } else {
  925. // This is not an error or warning.
  926. // So, figure out if this is a post-context line
  927. if (!this->ErrorsAndWarnings.empty() &&
  928. this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
  929. this->PostContextCount < this->MaxPostContext) {
  930. this->PostContextCount++;
  931. this->LastErrorOrWarning->PostContext += line;
  932. if (this->PostContextCount < this->MaxPostContext) {
  933. this->LastErrorOrWarning->PostContext += "\n";
  934. }
  935. } else {
  936. // Otherwise store pre-context for the next error
  937. this->PreContext.push_back(line);
  938. if (this->PreContext.size() > this->MaxPreContext) {
  939. this->PreContext.erase(this->PreContext.begin(),
  940. this->PreContext.end() -
  941. this->MaxPreContext);
  942. }
  943. }
  944. }
  945. this->OutputLineCounter++;
  946. } else {
  947. break;
  948. }
  949. }
  950. // Now that the buffer is processed, display missing ticks
  951. int tickDisplayed = false;
  952. while (this->BuildOutputLogSize > (tick * tick_len)) {
  953. tick++;
  954. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  955. this->LastTickChar, this->Quiet);
  956. tickDisplayed = true;
  957. if (tick % tick_line_len == 0 && tick > 0) {
  958. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  959. " Size: "
  960. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  961. << std::endl
  962. << " ",
  963. this->Quiet);
  964. }
  965. }
  966. if (tickDisplayed) {
  967. this->LastTickChar = '.';
  968. }
  969. // And if this is verbose output, display the content of the chunk
  970. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  971. cmCTestLogWrite(data, length));
  972. // Always store the chunk to the file
  973. ofs << cmCTestLogWrite(data, length);
  974. }
  975. int cmCTestBuildHandler::ProcessSingleLine(const char* data)
  976. {
  977. if (this->UseCTestLaunch) {
  978. // No log scraping when using launchers.
  979. return b_REGULAR_LINE;
  980. }
  981. cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
  982. this->Quiet);
  983. int warningLine = 0;
  984. int errorLine = 0;
  985. // Check for regular expressions
  986. if (!this->ErrorQuotaReached) {
  987. // Errors
  988. int wrxCnt = 0;
  989. for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
  990. if (rx.find(data)) {
  991. errorLine = 1;
  992. cmCTestOptionalLog(this->CTest, DEBUG,
  993. " Error Line: " << data << " (matches: "
  994. << this->CustomErrorMatches[wrxCnt]
  995. << ")" << std::endl,
  996. this->Quiet);
  997. break;
  998. }
  999. wrxCnt++;
  1000. }
  1001. // Error exceptions
  1002. wrxCnt = 0;
  1003. for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
  1004. if (rx.find(data)) {
  1005. errorLine = 0;
  1006. cmCTestOptionalLog(this->CTest, DEBUG,
  1007. " Not an error Line: "
  1008. << data << " (matches: "
  1009. << this->CustomErrorExceptions[wrxCnt] << ")"
  1010. << std::endl,
  1011. this->Quiet);
  1012. break;
  1013. }
  1014. wrxCnt++;
  1015. }
  1016. }
  1017. if (!this->WarningQuotaReached) {
  1018. // Warnings
  1019. int wrxCnt = 0;
  1020. for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
  1021. if (rx.find(data)) {
  1022. warningLine = 1;
  1023. cmCTestOptionalLog(this->CTest, DEBUG,
  1024. " Warning Line: "
  1025. << data << " (matches: "
  1026. << this->CustomWarningMatches[wrxCnt] << ")"
  1027. << std::endl,
  1028. this->Quiet);
  1029. break;
  1030. }
  1031. wrxCnt++;
  1032. }
  1033. wrxCnt = 0;
  1034. // Warning exceptions
  1035. for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
  1036. if (rx.find(data)) {
  1037. warningLine = 0;
  1038. cmCTestOptionalLog(this->CTest, DEBUG,
  1039. " Not a warning Line: "
  1040. << data << " (matches: "
  1041. << this->CustomWarningExceptions[wrxCnt] << ")"
  1042. << std::endl,
  1043. this->Quiet);
  1044. break;
  1045. }
  1046. wrxCnt++;
  1047. }
  1048. }
  1049. if (errorLine) {
  1050. return b_ERROR_LINE;
  1051. }
  1052. if (warningLine) {
  1053. return b_WARNING_LINE;
  1054. }
  1055. return b_REGULAR_LINE;
  1056. }