cmCTestBuildHandler.cxx 40 KB

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