cmCTestBuildHandler.cxx 39 KB

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