cmCTestBuildHandler.cxx 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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, "Problem Compiling regular expression: "
  273. << cmCTestWarningErrorFileLine[entry].RegularExpressionString
  274. << std::endl);
  275. }
  276. }
  277. // Determine build command and build directory
  278. std::string makeCommand = this->GetMakeCommand();
  279. if (makeCommand.empty()) {
  280. cmCTestLog(this->CTest, ERROR_MESSAGE,
  281. "Cannot find MakeCommand key in the DartConfiguration.tcl"
  282. << std::endl);
  283. return -1;
  284. }
  285. const std::string& buildDirectory =
  286. this->CTest->GetCTestConfiguration("BuildDirectory");
  287. if (buildDirectory.empty()) {
  288. cmCTestLog(this->CTest, ERROR_MESSAGE,
  289. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  290. << std::endl);
  291. return -1;
  292. }
  293. std::string const& useLaunchers =
  294. this->CTest->GetCTestConfiguration("UseLaunchers");
  295. this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers.c_str());
  296. // Create a last build log
  297. cmGeneratedFileStream ofs;
  298. auto elapsed_time_start = std::chrono::steady_clock::now();
  299. if (!this->StartLogFile("Build", ofs)) {
  300. cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
  301. << std::endl);
  302. }
  303. // Create lists of regular expression strings for errors, error exceptions,
  304. // warnings and warning exceptions.
  305. std::vector<std::string>::size_type cc;
  306. for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
  307. this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
  308. }
  309. for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
  310. this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
  311. }
  312. for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
  313. this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
  314. }
  315. for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
  316. this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
  317. }
  318. // Pre-compile regular expressions objects for all regular expressions
  319. #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
  320. regexes.clear(); \
  321. cmCTestOptionalLog(this->CTest, DEBUG, \
  322. this << "Add " #regexes << std::endl, this->Quiet); \
  323. for (std::string const& s : (strings)) { \
  324. cmCTestOptionalLog(this->CTest, DEBUG, \
  325. "Add " #strings ": " << s << std::endl, this->Quiet); \
  326. (regexes).push_back(s.c_str()); \
  327. }
  328. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
  329. this->ErrorMatchRegex);
  330. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
  331. this->ErrorExceptionRegex);
  332. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
  333. this->WarningMatchRegex);
  334. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
  335. this->WarningExceptionRegex);
  336. // Determine source and binary tree substitutions to simplify the output.
  337. this->SimplifySourceDir.clear();
  338. this->SimplifyBuildDir.clear();
  339. if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
  340. std::string srcdir =
  341. this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
  342. std::string srcdirrep;
  343. for (cc = srcdir.size() - 2; cc > 0; cc--) {
  344. if (srcdir[cc] == '/') {
  345. srcdirrep = srcdir.c_str() + cc;
  346. srcdirrep = "/..." + srcdirrep;
  347. srcdir = srcdir.substr(0, cc + 1);
  348. break;
  349. }
  350. }
  351. this->SimplifySourceDir = srcdir;
  352. }
  353. if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
  354. std::string bindir =
  355. this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
  356. std::string bindirrep;
  357. for (cc = bindir.size() - 2; cc > 0; cc--) {
  358. if (bindir[cc] == '/') {
  359. bindirrep = bindir.c_str() + cc;
  360. bindirrep = "/..." + bindirrep;
  361. bindir = bindir.substr(0, cc + 1);
  362. break;
  363. }
  364. }
  365. this->SimplifyBuildDir = bindir;
  366. }
  367. // Ok, let's do the build
  368. // Remember start build time
  369. this->StartBuild = this->CTest->CurrentTime();
  370. this->StartBuildTime = std::chrono::system_clock::now();
  371. int retVal = 0;
  372. int res = cmsysProcess_State_Exited;
  373. if (!this->CTest->GetShowOnly()) {
  374. res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
  375. buildDirectory.c_str(), 0, ofs);
  376. } else {
  377. cmCTestOptionalLog(this->CTest, DEBUG,
  378. "Build with command: " << makeCommand << std::endl,
  379. this->Quiet);
  380. }
  381. // Remember end build time and calculate elapsed time
  382. this->EndBuild = this->CTest->CurrentTime();
  383. this->EndBuildTime = std::chrono::system_clock::now();
  384. auto elapsed_build_time =
  385. std::chrono::steady_clock::now() - elapsed_time_start;
  386. // Cleanups strings in the errors and warnings list.
  387. if (!this->SimplifySourceDir.empty()) {
  388. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  389. cmSystemTools::ReplaceString(evit.Text, this->SimplifySourceDir.c_str(),
  390. "/.../");
  391. cmSystemTools::ReplaceString(evit.PreContext,
  392. this->SimplifySourceDir.c_str(), "/.../");
  393. cmSystemTools::ReplaceString(evit.PostContext,
  394. this->SimplifySourceDir.c_str(), "/.../");
  395. }
  396. }
  397. if (!this->SimplifyBuildDir.empty()) {
  398. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  399. cmSystemTools::ReplaceString(evit.Text, this->SimplifyBuildDir.c_str(),
  400. "/.../");
  401. cmSystemTools::ReplaceString(evit.PreContext,
  402. this->SimplifyBuildDir.c_str(), "/.../");
  403. cmSystemTools::ReplaceString(evit.PostContext,
  404. this->SimplifyBuildDir.c_str(), "/.../");
  405. }
  406. }
  407. // Generate XML output
  408. cmGeneratedFileStream xofs;
  409. if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
  410. cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file"
  411. << std::endl);
  412. return -1;
  413. }
  414. cmXMLWriter xml(xofs);
  415. this->GenerateXMLHeader(xml);
  416. if (this->UseCTestLaunch) {
  417. this->GenerateXMLLaunched(xml);
  418. } else {
  419. this->GenerateXMLLogScraped(xml);
  420. }
  421. this->GenerateXMLFooter(xml, elapsed_build_time);
  422. if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
  423. cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project"
  424. << std::endl);
  425. }
  426. // Display message about number of errors and warnings
  427. cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
  428. << this->TotalErrors
  429. << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
  430. << " Compiler errors" << std::endl);
  431. cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
  432. << this->TotalWarnings
  433. << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
  434. << " Compiler warnings" << std::endl);
  435. return retVal;
  436. }
  437. void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
  438. {
  439. this->CTest->StartXML(xml, this->AppendXML);
  440. this->CTest->GenerateSubprojectsOutput(xml);
  441. xml.StartElement("Build");
  442. xml.Element("StartDateTime", this->StartBuild);
  443. xml.Element("StartBuildTime", this->StartBuildTime);
  444. xml.Element("BuildCommand", this->GetMakeCommand());
  445. }
  446. class cmCTestBuildHandler::FragmentCompare
  447. {
  448. public:
  449. FragmentCompare(cmFileTimeComparison* ftc)
  450. : FTC(ftc)
  451. {
  452. }
  453. FragmentCompare()
  454. : FTC(nullptr)
  455. {
  456. }
  457. bool operator()(std::string const& l, std::string const& r) const
  458. {
  459. // Order files by modification time. Use lexicographic order
  460. // among files with the same time.
  461. int result;
  462. if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
  463. result != 0) {
  464. return result < 0;
  465. }
  466. return l < r;
  467. }
  468. private:
  469. cmFileTimeComparison* FTC;
  470. };
  471. void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
  472. {
  473. if (this->CTestLaunchDir.empty()) {
  474. return;
  475. }
  476. // Sort XML fragments in chronological order.
  477. cmFileTimeComparison ftc;
  478. FragmentCompare fragmentCompare(&ftc);
  479. typedef std::set<std::string, FragmentCompare> Fragments;
  480. Fragments fragments(fragmentCompare);
  481. // only report the first 50 warnings and first 50 errors
  482. int numErrorsAllowed = this->MaxErrors;
  483. int numWarningsAllowed = this->MaxWarnings;
  484. // Identify fragments on disk.
  485. cmsys::Directory launchDir;
  486. launchDir.Load(this->CTestLaunchDir);
  487. unsigned long n = launchDir.GetNumberOfFiles();
  488. for (unsigned long i = 0; i < n; ++i) {
  489. const char* fname = launchDir.GetFile(i);
  490. if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
  491. numErrorsAllowed--;
  492. fragments.insert(this->CTestLaunchDir + "/" + fname);
  493. ++this->TotalErrors;
  494. } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
  495. numWarningsAllowed--;
  496. fragments.insert(this->CTestLaunchDir + "/" + fname);
  497. ++this->TotalWarnings;
  498. }
  499. }
  500. // Copy the fragments into the final XML file.
  501. for (std::string const& f : fragments) {
  502. xml.FragmentFile(f.c_str());
  503. }
  504. }
  505. void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
  506. {
  507. std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
  508. std::vector<cmCTestBuildErrorWarning>::iterator it;
  509. // only report the first 50 warnings and first 50 errors
  510. int numErrorsAllowed = this->MaxErrors;
  511. int numWarningsAllowed = this->MaxWarnings;
  512. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  513. // make sure the source dir is in the correct case on windows
  514. // via a call to collapse full path.
  515. srcdir = cmSystemTools::CollapseFullPath(srcdir);
  516. srcdir += "/";
  517. for (it = ew.begin();
  518. it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
  519. cmCTestBuildErrorWarning* cm = &(*it);
  520. if ((cm->Error && numErrorsAllowed) ||
  521. (!cm->Error && numWarningsAllowed)) {
  522. if (cm->Error) {
  523. numErrorsAllowed--;
  524. } else {
  525. numWarningsAllowed--;
  526. }
  527. xml.StartElement(cm->Error ? "Error" : "Warning");
  528. xml.Element("BuildLogLine", cm->LogLine);
  529. xml.Element("Text", cm->Text);
  530. for (cmCTestCompileErrorWarningRex& rit :
  531. this->ErrorWarningFileLineRegex) {
  532. cmsys::RegularExpression* re = &rit.RegularExpression;
  533. if (re->find(cm->Text.c_str())) {
  534. cm->SourceFile = re->match(rit.FileIndex);
  535. // At this point we need to make this->SourceFile relative to
  536. // the source root of the project, so cvs links will work
  537. cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
  538. if (cm->SourceFile.find("/.../") != std::string::npos) {
  539. cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
  540. std::string::size_type p = cm->SourceFile.find('/');
  541. if (p != std::string::npos) {
  542. cm->SourceFile =
  543. cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
  544. }
  545. } else {
  546. // make sure it is a full path with the correct case
  547. cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
  548. cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
  549. }
  550. cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
  551. break;
  552. }
  553. }
  554. if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
  555. if (!cm->SourceFile.empty()) {
  556. xml.Element("SourceFile", cm->SourceFile);
  557. }
  558. if (!cm->SourceFileTail.empty()) {
  559. xml.Element("SourceFileTail", cm->SourceFileTail);
  560. }
  561. if (cm->LineNumber >= 0) {
  562. xml.Element("SourceLineNumber", cm->LineNumber);
  563. }
  564. }
  565. xml.Element("PreContext", cm->PreContext);
  566. xml.StartElement("PostContext");
  567. xml.Content(cm->PostContext);
  568. // is this the last warning or error, if so notify
  569. if ((cm->Error && !numErrorsAllowed) ||
  570. (!cm->Error && !numWarningsAllowed)) {
  571. xml.Content("\nThe maximum number of reported warnings or errors "
  572. "has been reached!!!\n");
  573. }
  574. xml.EndElement(); // PostContext
  575. xml.Element("RepeatCount", "0");
  576. xml.EndElement(); // "Error" / "Warning"
  577. }
  578. }
  579. }
  580. void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
  581. cmDuration elapsed_build_time)
  582. {
  583. xml.StartElement("Log");
  584. xml.Attribute("Encoding", "base64");
  585. xml.Attribute("Compression", "bin/gzip");
  586. xml.EndElement(); // Log
  587. xml.Element("EndDateTime", this->EndBuild);
  588. xml.Element("EndBuildTime", this->EndBuildTime);
  589. xml.Element(
  590. "ElapsedMinutes",
  591. std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
  592. .count());
  593. xml.EndElement(); // Build
  594. this->CTest->EndXML(xml);
  595. }
  596. bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
  597. {
  598. // error-{hash}.xml
  599. return (cmHasLiteralPrefix(fname, "error-") &&
  600. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  601. }
  602. bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
  603. {
  604. // warning-{hash}.xml
  605. return (cmHasLiteralPrefix(fname, "warning-") &&
  606. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  607. }
  608. //######################################################################
  609. //######################################################################
  610. //######################################################################
  611. //######################################################################
  612. class cmCTestBuildHandler::LaunchHelper
  613. {
  614. public:
  615. LaunchHelper(cmCTestBuildHandler* handler);
  616. ~LaunchHelper();
  617. private:
  618. cmCTestBuildHandler* Handler;
  619. cmCTest* CTest;
  620. void WriteLauncherConfig();
  621. void WriteScrapeMatchers(const char* purpose,
  622. std::vector<std::string> const& matchers);
  623. };
  624. cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
  625. : Handler(handler)
  626. , CTest(handler->CTest)
  627. {
  628. std::string tag = this->CTest->GetCurrentTag();
  629. if (tag.empty()) {
  630. // This is not for a dashboard submission, so there is no XML.
  631. // Skip enabling the launchers.
  632. this->Handler->UseCTestLaunch = false;
  633. } else {
  634. // Compute a directory in which to store launcher fragments.
  635. std::string& launchDir = this->Handler->CTestLaunchDir;
  636. launchDir = this->CTest->GetBinaryDir();
  637. launchDir += "/Testing/";
  638. launchDir += tag;
  639. launchDir += "/Build";
  640. // Clean out any existing launcher fragments.
  641. cmSystemTools::RemoveADirectory(launchDir);
  642. if (this->Handler->UseCTestLaunch) {
  643. // Enable launcher fragments.
  644. cmSystemTools::MakeDirectory(launchDir);
  645. this->WriteLauncherConfig();
  646. std::string launchEnv = "CTEST_LAUNCH_LOGS=";
  647. launchEnv += launchDir;
  648. cmSystemTools::PutEnv(launchEnv);
  649. }
  650. }
  651. // If not using launchers, make sure they passthru.
  652. if (!this->Handler->UseCTestLaunch) {
  653. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  654. }
  655. }
  656. cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
  657. {
  658. if (this->Handler->UseCTestLaunch) {
  659. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  660. }
  661. }
  662. void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
  663. {
  664. this->WriteScrapeMatchers("Warning",
  665. this->Handler->ReallyCustomWarningMatches);
  666. this->WriteScrapeMatchers("WarningSuppress",
  667. this->Handler->ReallyCustomWarningExceptions);
  668. // Give some testing configuration information to the launcher.
  669. std::string fname = this->Handler->CTestLaunchDir;
  670. fname += "/CTestLaunchConfig.cmake";
  671. cmGeneratedFileStream fout(fname.c_str());
  672. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  673. fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
  674. }
  675. void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
  676. const char* purpose, std::vector<std::string> const& matchers)
  677. {
  678. if (matchers.empty()) {
  679. return;
  680. }
  681. std::string fname = this->Handler->CTestLaunchDir;
  682. fname += "/Custom";
  683. fname += purpose;
  684. fname += ".txt";
  685. cmGeneratedFileStream fout(fname.c_str());
  686. for (std::string const& m : matchers) {
  687. fout << m << "\n";
  688. }
  689. }
  690. int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
  691. const char* dir, int timeout,
  692. std::ostream& ofs, Encoding encoding)
  693. {
  694. // First generate the command and arguments
  695. std::vector<std::string> args = cmSystemTools::ParseArguments(command);
  696. if (args.empty()) {
  697. return false;
  698. }
  699. std::vector<const char*> argv;
  700. argv.reserve(args.size() + 1);
  701. for (std::string const& arg : args) {
  702. argv.push_back(arg.c_str());
  703. }
  704. argv.push_back(nullptr);
  705. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
  706. this->Quiet);
  707. for (char const* arg : argv) {
  708. if (!arg) {
  709. break;
  710. }
  711. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  712. " \"" << arg << "\"", this->Quiet);
  713. }
  714. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
  715. this->Quiet);
  716. // Optionally use make rule launchers to record errors and warnings.
  717. LaunchHelper launchHelper(this);
  718. static_cast<void>(launchHelper);
  719. // Now create process object
  720. cmsysProcess* cp = cmsysProcess_New();
  721. cmsysProcess_SetCommand(cp, &*argv.begin());
  722. cmsysProcess_SetWorkingDirectory(cp, dir);
  723. cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
  724. cmsysProcess_SetTimeout(cp, timeout);
  725. cmsysProcess_Execute(cp);
  726. // Initialize tick's
  727. std::string::size_type tick = 0;
  728. const std::string::size_type tick_len = 1024;
  729. char* data;
  730. int length;
  731. cmProcessOutput processOutput(encoding);
  732. std::string strdata;
  733. cmCTestOptionalLog(
  734. this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents "
  735. << tick_len << " bytes of output." << std::endl
  736. << (this->UseCTestLaunch
  737. ? ""
  738. : " '!' represents an error and '*' a warning.\n")
  739. << " " << std::flush,
  740. this->Quiet);
  741. // Initialize building structures
  742. this->BuildProcessingQueue.clear();
  743. this->OutputLineCounter = 0;
  744. this->ErrorsAndWarnings.clear();
  745. this->TotalErrors = 0;
  746. this->TotalWarnings = 0;
  747. this->BuildOutputLogSize = 0;
  748. this->LastTickChar = '.';
  749. this->WarningQuotaReached = false;
  750. this->ErrorQuotaReached = false;
  751. // For every chunk of data
  752. int res;
  753. while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
  754. // Replace '\0' with '\n', since '\0' does not really make sense. This is
  755. // for Visual Studio output
  756. for (int cc = 0; cc < length; ++cc) {
  757. if (data[cc] == 0) {
  758. data[cc] = '\n';
  759. }
  760. }
  761. // Process the chunk of data
  762. if (res == cmsysProcess_Pipe_STDERR) {
  763. processOutput.DecodeText(data, length, strdata, 1);
  764. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  765. &this->BuildProcessingErrorQueue);
  766. } else {
  767. processOutput.DecodeText(data, length, strdata, 2);
  768. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  769. &this->BuildProcessingQueue);
  770. }
  771. }
  772. processOutput.DecodeText(std::string(), strdata, 1);
  773. if (!strdata.empty()) {
  774. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  775. &this->BuildProcessingErrorQueue);
  776. }
  777. processOutput.DecodeText(std::string(), strdata, 2);
  778. if (!strdata.empty()) {
  779. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  780. &this->BuildProcessingQueue);
  781. }
  782. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  783. &this->BuildProcessingQueue);
  784. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  785. &this->BuildProcessingErrorQueue);
  786. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: "
  787. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  788. << std::endl,
  789. this->Quiet);
  790. // Properly handle output of the build command
  791. cmsysProcess_WaitForExit(cp, nullptr);
  792. int result = cmsysProcess_GetState(cp);
  793. if (result == cmsysProcess_State_Exited) {
  794. if (retVal) {
  795. *retVal = cmsysProcess_GetExitValue(cp);
  796. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  797. "Command exited with the value: " << *retVal
  798. << std::endl,
  799. this->Quiet);
  800. // if a non zero return value
  801. if (*retVal) {
  802. // If there was an error running command, report that on the
  803. // dashboard.
  804. cmCTestBuildErrorWarning errorwarning;
  805. errorwarning.LogLine = 1;
  806. errorwarning.Text =
  807. "*** WARNING non-zero return value in ctest from: ";
  808. errorwarning.Text += argv[0];
  809. errorwarning.PreContext.clear();
  810. errorwarning.PostContext.clear();
  811. errorwarning.Error = false;
  812. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  813. this->TotalWarnings++;
  814. }
  815. }
  816. } else if (result == cmsysProcess_State_Exception) {
  817. if (retVal) {
  818. *retVal = cmsysProcess_GetExitException(cp);
  819. cmCTestOptionalLog(this->CTest, WARNING,
  820. "There was an exception: " << *retVal << std::endl,
  821. this->Quiet);
  822. }
  823. } else if (result == cmsysProcess_State_Expired) {
  824. cmCTestOptionalLog(this->CTest, WARNING,
  825. "There was a timeout" << std::endl, this->Quiet);
  826. } else if (result == cmsysProcess_State_Error) {
  827. // If there was an error running command, report that on the dashboard.
  828. cmCTestBuildErrorWarning errorwarning;
  829. errorwarning.LogLine = 1;
  830. errorwarning.Text = "*** ERROR executing: ";
  831. errorwarning.Text += cmsysProcess_GetErrorString(cp);
  832. errorwarning.PreContext.clear();
  833. errorwarning.PostContext.clear();
  834. errorwarning.Error = true;
  835. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  836. this->TotalErrors++;
  837. cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
  838. << cmsysProcess_GetErrorString(cp) << std::endl);
  839. }
  840. cmsysProcess_Delete(cp);
  841. return result;
  842. }
  843. //######################################################################
  844. //######################################################################
  845. //######################################################################
  846. //######################################################################
  847. void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
  848. size_t& tick, size_t tick_len,
  849. std::ostream& ofs,
  850. t_BuildProcessingQueueType* queue)
  851. {
  852. const std::string::size_type tick_line_len = 50;
  853. const char* ptr;
  854. for (ptr = data; ptr < data + length; ptr++) {
  855. queue->push_back(*ptr);
  856. }
  857. this->BuildOutputLogSize += length;
  858. // until there are any lines left in the buffer
  859. while (true) {
  860. // Find the end of line
  861. t_BuildProcessingQueueType::iterator it;
  862. for (it = queue->begin(); it != queue->end(); ++it) {
  863. if (*it == '\n') {
  864. break;
  865. }
  866. }
  867. // Once certain number of errors or warnings reached, ignore future errors
  868. // or warnings.
  869. if (this->TotalWarnings >= this->MaxWarnings) {
  870. this->WarningQuotaReached = true;
  871. }
  872. if (this->TotalErrors >= this->MaxErrors) {
  873. this->ErrorQuotaReached = true;
  874. }
  875. // If the end of line was found
  876. if (it != queue->end()) {
  877. // Create a contiguous array for the line
  878. this->CurrentProcessingLine.clear();
  879. this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
  880. queue->begin(), it);
  881. this->CurrentProcessingLine.push_back(0);
  882. const char* line = &*this->CurrentProcessingLine.begin();
  883. // Process the line
  884. int lineType = this->ProcessSingleLine(line);
  885. // Erase the line from the queue
  886. queue->erase(queue->begin(), it + 1);
  887. // Depending on the line type, produce error or warning, or nothing
  888. cmCTestBuildErrorWarning errorwarning;
  889. bool found = false;
  890. switch (lineType) {
  891. case b_WARNING_LINE:
  892. this->LastTickChar = '*';
  893. errorwarning.Error = false;
  894. found = true;
  895. this->TotalWarnings++;
  896. break;
  897. case b_ERROR_LINE:
  898. this->LastTickChar = '!';
  899. errorwarning.Error = true;
  900. found = true;
  901. this->TotalErrors++;
  902. break;
  903. }
  904. if (found) {
  905. // This is an error or warning, so generate report
  906. errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
  907. errorwarning.Text = line;
  908. errorwarning.PreContext.clear();
  909. errorwarning.PostContext.clear();
  910. // Copy pre-context to report
  911. for (std::string const& pc : this->PreContext) {
  912. errorwarning.PreContext += pc + "\n";
  913. }
  914. this->PreContext.clear();
  915. // Store report
  916. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  917. this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
  918. this->PostContextCount = 0;
  919. } else {
  920. // This is not an error or warning.
  921. // So, figure out if this is a post-context line
  922. if (!this->ErrorsAndWarnings.empty() &&
  923. this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
  924. this->PostContextCount < this->MaxPostContext) {
  925. this->PostContextCount++;
  926. this->LastErrorOrWarning->PostContext += line;
  927. if (this->PostContextCount < this->MaxPostContext) {
  928. this->LastErrorOrWarning->PostContext += "\n";
  929. }
  930. } else {
  931. // Otherwise store pre-context for the next error
  932. this->PreContext.push_back(line);
  933. if (this->PreContext.size() > this->MaxPreContext) {
  934. this->PreContext.erase(this->PreContext.begin(),
  935. this->PreContext.end() -
  936. this->MaxPreContext);
  937. }
  938. }
  939. }
  940. this->OutputLineCounter++;
  941. } else {
  942. break;
  943. }
  944. }
  945. // Now that the buffer is processed, display missing ticks
  946. int tickDisplayed = false;
  947. while (this->BuildOutputLogSize > (tick * tick_len)) {
  948. tick++;
  949. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  950. this->LastTickChar, this->Quiet);
  951. tickDisplayed = true;
  952. if (tick % tick_line_len == 0 && tick > 0) {
  953. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size: "
  954. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  955. << std::endl
  956. << " ",
  957. this->Quiet);
  958. }
  959. }
  960. if (tickDisplayed) {
  961. this->LastTickChar = '.';
  962. }
  963. // And if this is verbose output, display the content of the chunk
  964. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  965. cmCTestLogWrite(data, length));
  966. // Always store the chunk to the file
  967. ofs << cmCTestLogWrite(data, length);
  968. }
  969. int cmCTestBuildHandler::ProcessSingleLine(const char* data)
  970. {
  971. if (this->UseCTestLaunch) {
  972. // No log scraping when using launchers.
  973. return b_REGULAR_LINE;
  974. }
  975. cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
  976. this->Quiet);
  977. int warningLine = 0;
  978. int errorLine = 0;
  979. // Check for regular expressions
  980. if (!this->ErrorQuotaReached) {
  981. // Errors
  982. int wrxCnt = 0;
  983. for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
  984. if (rx.find(data)) {
  985. errorLine = 1;
  986. cmCTestOptionalLog(this->CTest, DEBUG,
  987. " Error Line: " << data << " (matches: "
  988. << this->CustomErrorMatches[wrxCnt]
  989. << ")" << std::endl,
  990. this->Quiet);
  991. break;
  992. }
  993. wrxCnt++;
  994. }
  995. // Error exceptions
  996. wrxCnt = 0;
  997. for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
  998. if (rx.find(data)) {
  999. errorLine = 0;
  1000. cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: "
  1001. << data << " (matches: "
  1002. << this->CustomErrorExceptions[wrxCnt] << ")"
  1003. << std::endl,
  1004. this->Quiet);
  1005. break;
  1006. }
  1007. wrxCnt++;
  1008. }
  1009. }
  1010. if (!this->WarningQuotaReached) {
  1011. // Warnings
  1012. int wrxCnt = 0;
  1013. for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
  1014. if (rx.find(data)) {
  1015. warningLine = 1;
  1016. cmCTestOptionalLog(this->CTest, DEBUG, " Warning Line: "
  1017. << data << " (matches: "
  1018. << this->CustomWarningMatches[wrxCnt] << ")"
  1019. << std::endl,
  1020. this->Quiet);
  1021. break;
  1022. }
  1023. wrxCnt++;
  1024. }
  1025. wrxCnt = 0;
  1026. // Warning exceptions
  1027. for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
  1028. if (rx.find(data)) {
  1029. warningLine = 0;
  1030. cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: "
  1031. << data << " (matches: "
  1032. << this->CustomWarningExceptions[wrxCnt] << ")"
  1033. << std::endl,
  1034. this->Quiet);
  1035. break;
  1036. }
  1037. wrxCnt++;
  1038. }
  1039. }
  1040. if (errorLine) {
  1041. return b_ERROR_LINE;
  1042. }
  1043. if (warningLine) {
  1044. return b_WARNING_LINE;
  1045. }
  1046. return b_REGULAR_LINE;
  1047. }