cmCTestBuildHandler.cxx 39 KB

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