cmCTestBuildHandler.cxx 39 KB

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