cmCTestBuildHandler.cxx 39 KB

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