cmCTestBuildHandler.cxx 39 KB

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