cmCTestBuildHandler.cxx 39 KB

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