cmCTestBuildHandler.cxx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  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 "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.emplace_back(cmCTestErrorMatches[cc]);
  310. }
  311. for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
  312. this->CustomErrorExceptions.emplace_back(cmCTestErrorExceptions[cc]);
  313. }
  314. for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
  315. this->CustomWarningMatches.emplace_back(cmCTestWarningMatches[cc]);
  316. }
  317. for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
  318. this->CustomWarningExceptions.emplace_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).emplace_back(s); \
  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, &retVal, buildDirectory.c_str(), 0,
  380. 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(cmFileTimeCache* ftc)
  456. : FTC(ftc)
  457. {
  458. }
  459. FragmentCompare() = default;
  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->Compare(l, r, &result) && result != 0) {
  466. return result < 0;
  467. }
  468. return l < r;
  469. }
  470. private:
  471. cmFileTimeCache* FTC = nullptr;
  472. };
  473. void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
  474. {
  475. if (this->CTestLaunchDir.empty()) {
  476. return;
  477. }
  478. // Sort XML fragments in chronological order.
  479. cmFileTimeCache ftc;
  480. FragmentCompare fragmentCompare(&ftc);
  481. typedef std::set<std::string, FragmentCompare> Fragments;
  482. Fragments fragments(fragmentCompare);
  483. // only report the first 50 warnings and first 50 errors
  484. int numErrorsAllowed = this->MaxErrors;
  485. int numWarningsAllowed = this->MaxWarnings;
  486. // Identify fragments on disk.
  487. cmsys::Directory launchDir;
  488. launchDir.Load(this->CTestLaunchDir);
  489. unsigned long n = launchDir.GetNumberOfFiles();
  490. for (unsigned long i = 0; i < n; ++i) {
  491. const char* fname = launchDir.GetFile(i);
  492. if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
  493. numErrorsAllowed--;
  494. fragments.insert(this->CTestLaunchDir + "/" + fname);
  495. ++this->TotalErrors;
  496. } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
  497. numWarningsAllowed--;
  498. fragments.insert(this->CTestLaunchDir + "/" + fname);
  499. ++this->TotalWarnings;
  500. }
  501. }
  502. // Copy the fragments into the final XML file.
  503. for (std::string const& f : fragments) {
  504. xml.FragmentFile(f.c_str());
  505. }
  506. }
  507. void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
  508. {
  509. std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
  510. std::vector<cmCTestBuildErrorWarning>::iterator it;
  511. // only report the first 50 warnings and first 50 errors
  512. int numErrorsAllowed = this->MaxErrors;
  513. int numWarningsAllowed = this->MaxWarnings;
  514. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  515. // make sure the source dir is in the correct case on windows
  516. // via a call to collapse full path.
  517. srcdir = cmSystemTools::CollapseFullPath(srcdir);
  518. srcdir += "/";
  519. for (it = ew.begin();
  520. it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
  521. cmCTestBuildErrorWarning* cm = &(*it);
  522. if ((cm->Error && numErrorsAllowed) ||
  523. (!cm->Error && numWarningsAllowed)) {
  524. if (cm->Error) {
  525. numErrorsAllowed--;
  526. } else {
  527. numWarningsAllowed--;
  528. }
  529. xml.StartElement(cm->Error ? "Error" : "Warning");
  530. xml.Element("BuildLogLine", cm->LogLine);
  531. xml.Element("Text", cm->Text);
  532. for (cmCTestCompileErrorWarningRex& rit :
  533. this->ErrorWarningFileLineRegex) {
  534. cmsys::RegularExpression* re = &rit.RegularExpression;
  535. if (re->find(cm->Text)) {
  536. cm->SourceFile = re->match(rit.FileIndex);
  537. // At this point we need to make this->SourceFile relative to
  538. // the source root of the project, so cvs links will work
  539. cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
  540. if (cm->SourceFile.find("/.../") != std::string::npos) {
  541. cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
  542. std::string::size_type p = cm->SourceFile.find('/');
  543. if (p != std::string::npos) {
  544. cm->SourceFile =
  545. cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
  546. }
  547. } else {
  548. // make sure it is a full path with the correct case
  549. cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
  550. cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
  551. }
  552. cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
  553. break;
  554. }
  555. }
  556. if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
  557. if (!cm->SourceFile.empty()) {
  558. xml.Element("SourceFile", cm->SourceFile);
  559. }
  560. if (!cm->SourceFileTail.empty()) {
  561. xml.Element("SourceFileTail", cm->SourceFileTail);
  562. }
  563. if (cm->LineNumber >= 0) {
  564. xml.Element("SourceLineNumber", cm->LineNumber);
  565. }
  566. }
  567. xml.Element("PreContext", cm->PreContext);
  568. xml.StartElement("PostContext");
  569. xml.Content(cm->PostContext);
  570. // is this the last warning or error, if so notify
  571. if ((cm->Error && !numErrorsAllowed) ||
  572. (!cm->Error && !numWarningsAllowed)) {
  573. xml.Content("\nThe maximum number of reported warnings or errors "
  574. "has been reached!!!\n");
  575. }
  576. xml.EndElement(); // PostContext
  577. xml.Element("RepeatCount", "0");
  578. xml.EndElement(); // "Error" / "Warning"
  579. }
  580. }
  581. }
  582. void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
  583. cmDuration elapsed_build_time)
  584. {
  585. xml.StartElement("Log");
  586. xml.Attribute("Encoding", "base64");
  587. xml.Attribute("Compression", "bin/gzip");
  588. xml.EndElement(); // Log
  589. xml.Element("EndDateTime", this->EndBuild);
  590. xml.Element("EndBuildTime", this->EndBuildTime);
  591. xml.Element(
  592. "ElapsedMinutes",
  593. std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
  594. .count());
  595. xml.EndElement(); // Build
  596. this->CTest->EndXML(xml);
  597. }
  598. bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
  599. {
  600. // error-{hash}.xml
  601. return (cmHasLiteralPrefix(fname, "error-") &&
  602. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  603. }
  604. bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
  605. {
  606. // warning-{hash}.xml
  607. return (cmHasLiteralPrefix(fname, "warning-") &&
  608. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  609. }
  610. //######################################################################
  611. //######################################################################
  612. //######################################################################
  613. //######################################################################
  614. class cmCTestBuildHandler::LaunchHelper
  615. {
  616. public:
  617. LaunchHelper(cmCTestBuildHandler* handler);
  618. ~LaunchHelper();
  619. LaunchHelper(const LaunchHelper&) = delete;
  620. LaunchHelper& operator=(const LaunchHelper&) = delete;
  621. private:
  622. cmCTestBuildHandler* Handler;
  623. cmCTest* CTest;
  624. void WriteLauncherConfig();
  625. void WriteScrapeMatchers(const char* purpose,
  626. std::vector<std::string> const& matchers);
  627. };
  628. cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
  629. : Handler(handler)
  630. , CTest(handler->CTest)
  631. {
  632. std::string tag = this->CTest->GetCurrentTag();
  633. if (tag.empty()) {
  634. // This is not for a dashboard submission, so there is no XML.
  635. // Skip enabling the launchers.
  636. this->Handler->UseCTestLaunch = false;
  637. } else {
  638. // Compute a directory in which to store launcher fragments.
  639. std::string& launchDir = this->Handler->CTestLaunchDir;
  640. launchDir = this->CTest->GetBinaryDir();
  641. launchDir += "/Testing/";
  642. launchDir += tag;
  643. launchDir += "/Build";
  644. // Clean out any existing launcher fragments.
  645. cmSystemTools::RemoveADirectory(launchDir);
  646. if (this->Handler->UseCTestLaunch) {
  647. // Enable launcher fragments.
  648. cmSystemTools::MakeDirectory(launchDir);
  649. this->WriteLauncherConfig();
  650. std::string launchEnv = "CTEST_LAUNCH_LOGS=";
  651. launchEnv += launchDir;
  652. cmSystemTools::PutEnv(launchEnv);
  653. }
  654. }
  655. // If not using launchers, make sure they passthru.
  656. if (!this->Handler->UseCTestLaunch) {
  657. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  658. }
  659. }
  660. cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
  661. {
  662. if (this->Handler->UseCTestLaunch) {
  663. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  664. }
  665. }
  666. void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
  667. {
  668. this->WriteScrapeMatchers("Warning",
  669. this->Handler->ReallyCustomWarningMatches);
  670. this->WriteScrapeMatchers("WarningSuppress",
  671. this->Handler->ReallyCustomWarningExceptions);
  672. // Give some testing configuration information to the launcher.
  673. std::string fname = this->Handler->CTestLaunchDir;
  674. fname += "/CTestLaunchConfig.cmake";
  675. cmGeneratedFileStream fout(fname);
  676. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  677. fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
  678. }
  679. void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
  680. const char* purpose, std::vector<std::string> const& matchers)
  681. {
  682. if (matchers.empty()) {
  683. return;
  684. }
  685. std::string fname = this->Handler->CTestLaunchDir;
  686. fname += "/Custom";
  687. fname += purpose;
  688. fname += ".txt";
  689. cmGeneratedFileStream fout(fname);
  690. for (std::string const& m : matchers) {
  691. fout << m << "\n";
  692. }
  693. }
  694. int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
  695. int* retVal, const char* dir,
  696. int timeout, std::ostream& ofs,
  697. Encoding encoding)
  698. {
  699. // First generate the command and arguments
  700. std::vector<std::string> args = cmSystemTools::ParseArguments(command);
  701. if (args.empty()) {
  702. return false;
  703. }
  704. std::vector<const char*> argv;
  705. argv.reserve(args.size() + 1);
  706. for (std::string const& arg : args) {
  707. argv.push_back(arg.c_str());
  708. }
  709. argv.push_back(nullptr);
  710. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  711. "Run command:", this->Quiet);
  712. for (char const* arg : argv) {
  713. if (!arg) {
  714. break;
  715. }
  716. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  717. " \"" << arg << "\"", this->Quiet);
  718. }
  719. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
  720. this->Quiet);
  721. // Optionally use make rule launchers to record errors and warnings.
  722. LaunchHelper launchHelper(this);
  723. static_cast<void>(launchHelper);
  724. // Now create process object
  725. cmsysProcess* cp = cmsysProcess_New();
  726. cmsysProcess_SetCommand(cp, argv.data());
  727. cmsysProcess_SetWorkingDirectory(cp, dir);
  728. cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
  729. cmsysProcess_SetTimeout(cp, timeout);
  730. cmsysProcess_Execute(cp);
  731. // Initialize tick's
  732. std::string::size_type tick = 0;
  733. const std::string::size_type tick_len = 1024;
  734. char* data;
  735. int length;
  736. cmProcessOutput processOutput(encoding);
  737. std::string strdata;
  738. cmCTestOptionalLog(
  739. this->CTest, HANDLER_PROGRESS_OUTPUT,
  740. " Each symbol represents "
  741. << tick_len << " bytes of output." << std::endl
  742. << (this->UseCTestLaunch
  743. ? ""
  744. : " '!' represents an error and '*' a warning.\n")
  745. << " " << std::flush,
  746. this->Quiet);
  747. // Initialize building structures
  748. this->BuildProcessingQueue.clear();
  749. this->OutputLineCounter = 0;
  750. this->ErrorsAndWarnings.clear();
  751. this->TotalErrors = 0;
  752. this->TotalWarnings = 0;
  753. this->BuildOutputLogSize = 0;
  754. this->LastTickChar = '.';
  755. this->WarningQuotaReached = false;
  756. this->ErrorQuotaReached = false;
  757. // For every chunk of data
  758. int res;
  759. while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
  760. // Replace '\0' with '\n', since '\0' does not really make sense. This is
  761. // for Visual Studio output
  762. for (int cc = 0; cc < length; ++cc) {
  763. if (data[cc] == 0) {
  764. data[cc] = '\n';
  765. }
  766. }
  767. // Process the chunk of data
  768. if (res == cmsysProcess_Pipe_STDERR) {
  769. processOutput.DecodeText(data, length, strdata, 1);
  770. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  771. &this->BuildProcessingErrorQueue);
  772. } else {
  773. processOutput.DecodeText(data, length, strdata, 2);
  774. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  775. &this->BuildProcessingQueue);
  776. }
  777. }
  778. processOutput.DecodeText(std::string(), strdata, 1);
  779. if (!strdata.empty()) {
  780. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  781. &this->BuildProcessingErrorQueue);
  782. }
  783. processOutput.DecodeText(std::string(), strdata, 2);
  784. if (!strdata.empty()) {
  785. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  786. &this->BuildProcessingQueue);
  787. }
  788. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  789. &this->BuildProcessingQueue);
  790. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  791. &this->BuildProcessingErrorQueue);
  792. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  793. " Size of output: "
  794. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  795. << std::endl,
  796. this->Quiet);
  797. // Properly handle output of the build command
  798. cmsysProcess_WaitForExit(cp, nullptr);
  799. int result = cmsysProcess_GetState(cp);
  800. if (result == cmsysProcess_State_Exited) {
  801. if (retVal) {
  802. *retVal = cmsysProcess_GetExitValue(cp);
  803. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  804. "Command exited with the value: " << *retVal
  805. << std::endl,
  806. this->Quiet);
  807. // if a non zero return value
  808. if (*retVal) {
  809. // If there was an error running command, report that on the
  810. // dashboard.
  811. cmCTestBuildErrorWarning errorwarning;
  812. errorwarning.LogLine = 1;
  813. errorwarning.Text =
  814. "*** WARNING non-zero return value in ctest from: ";
  815. errorwarning.Text += argv[0];
  816. errorwarning.PreContext.clear();
  817. errorwarning.PostContext.clear();
  818. errorwarning.Error = false;
  819. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  820. this->TotalWarnings++;
  821. }
  822. }
  823. } else if (result == cmsysProcess_State_Exception) {
  824. if (retVal) {
  825. *retVal = cmsysProcess_GetExitException(cp);
  826. cmCTestOptionalLog(this->CTest, WARNING,
  827. "There was an exception: " << *retVal << std::endl,
  828. this->Quiet);
  829. }
  830. } else if (result == cmsysProcess_State_Expired) {
  831. cmCTestOptionalLog(this->CTest, WARNING,
  832. "There was a timeout" << std::endl, this->Quiet);
  833. } else if (result == cmsysProcess_State_Error) {
  834. // If there was an error running command, report that on the dashboard.
  835. cmCTestBuildErrorWarning errorwarning;
  836. errorwarning.LogLine = 1;
  837. errorwarning.Text = "*** ERROR executing: ";
  838. errorwarning.Text += cmsysProcess_GetErrorString(cp);
  839. errorwarning.PreContext.clear();
  840. errorwarning.PostContext.clear();
  841. errorwarning.Error = true;
  842. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  843. this->TotalErrors++;
  844. cmCTestLog(this->CTest, ERROR_MESSAGE,
  845. "There was an error: " << cmsysProcess_GetErrorString(cp)
  846. << std::endl);
  847. }
  848. cmsysProcess_Delete(cp);
  849. return result;
  850. }
  851. //######################################################################
  852. //######################################################################
  853. //######################################################################
  854. //######################################################################
  855. void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
  856. size_t& tick, size_t tick_len,
  857. std::ostream& ofs,
  858. t_BuildProcessingQueueType* queue)
  859. {
  860. const std::string::size_type tick_line_len = 50;
  861. const char* ptr;
  862. for (ptr = data; ptr < data + length; ptr++) {
  863. queue->push_back(*ptr);
  864. }
  865. this->BuildOutputLogSize += length;
  866. // until there are any lines left in the buffer
  867. while (true) {
  868. // Find the end of line
  869. t_BuildProcessingQueueType::iterator it;
  870. for (it = queue->begin(); it != queue->end(); ++it) {
  871. if (*it == '\n') {
  872. break;
  873. }
  874. }
  875. // Once certain number of errors or warnings reached, ignore future errors
  876. // or warnings.
  877. if (this->TotalWarnings >= this->MaxWarnings) {
  878. this->WarningQuotaReached = true;
  879. }
  880. if (this->TotalErrors >= this->MaxErrors) {
  881. this->ErrorQuotaReached = true;
  882. }
  883. // If the end of line was found
  884. if (it != queue->end()) {
  885. // Create a contiguous array for the line
  886. this->CurrentProcessingLine.clear();
  887. this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
  888. queue->begin(), it);
  889. this->CurrentProcessingLine.push_back(0);
  890. const char* line = this->CurrentProcessingLine.data();
  891. // Process the line
  892. int lineType = this->ProcessSingleLine(line);
  893. // Erase the line from the queue
  894. queue->erase(queue->begin(), it + 1);
  895. // Depending on the line type, produce error or warning, or nothing
  896. cmCTestBuildErrorWarning errorwarning;
  897. bool found = false;
  898. switch (lineType) {
  899. case b_WARNING_LINE:
  900. this->LastTickChar = '*';
  901. errorwarning.Error = false;
  902. found = true;
  903. this->TotalWarnings++;
  904. break;
  905. case b_ERROR_LINE:
  906. this->LastTickChar = '!';
  907. errorwarning.Error = true;
  908. found = true;
  909. this->TotalErrors++;
  910. break;
  911. }
  912. if (found) {
  913. // This is an error or warning, so generate report
  914. errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
  915. errorwarning.Text = line;
  916. errorwarning.PreContext.clear();
  917. errorwarning.PostContext.clear();
  918. // Copy pre-context to report
  919. for (std::string const& pc : this->PreContext) {
  920. errorwarning.PreContext += pc + "\n";
  921. }
  922. this->PreContext.clear();
  923. // Store report
  924. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  925. this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
  926. this->PostContextCount = 0;
  927. } else {
  928. // This is not an error or warning.
  929. // So, figure out if this is a post-context line
  930. if (!this->ErrorsAndWarnings.empty() &&
  931. this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
  932. this->PostContextCount < this->MaxPostContext) {
  933. this->PostContextCount++;
  934. this->LastErrorOrWarning->PostContext += line;
  935. if (this->PostContextCount < this->MaxPostContext) {
  936. this->LastErrorOrWarning->PostContext += "\n";
  937. }
  938. } else {
  939. // Otherwise store pre-context for the next error
  940. this->PreContext.emplace_back(line);
  941. if (this->PreContext.size() > this->MaxPreContext) {
  942. this->PreContext.erase(this->PreContext.begin(),
  943. this->PreContext.end() -
  944. this->MaxPreContext);
  945. }
  946. }
  947. }
  948. this->OutputLineCounter++;
  949. } else {
  950. break;
  951. }
  952. }
  953. // Now that the buffer is processed, display missing ticks
  954. int tickDisplayed = false;
  955. while (this->BuildOutputLogSize > (tick * tick_len)) {
  956. tick++;
  957. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  958. this->LastTickChar, this->Quiet);
  959. tickDisplayed = true;
  960. if (tick % tick_line_len == 0 && tick > 0) {
  961. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  962. " Size: "
  963. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  964. << std::endl
  965. << " ",
  966. this->Quiet);
  967. }
  968. }
  969. if (tickDisplayed) {
  970. this->LastTickChar = '.';
  971. }
  972. // And if this is verbose output, display the content of the chunk
  973. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  974. cmCTestLogWrite(data, length));
  975. // Always store the chunk to the file
  976. ofs << cmCTestLogWrite(data, length);
  977. }
  978. int cmCTestBuildHandler::ProcessSingleLine(const char* data)
  979. {
  980. if (this->UseCTestLaunch) {
  981. // No log scraping when using launchers.
  982. return b_REGULAR_LINE;
  983. }
  984. cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
  985. this->Quiet);
  986. int warningLine = 0;
  987. int errorLine = 0;
  988. // Check for regular expressions
  989. if (!this->ErrorQuotaReached) {
  990. // Errors
  991. int wrxCnt = 0;
  992. for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
  993. if (rx.find(data)) {
  994. errorLine = 1;
  995. cmCTestOptionalLog(this->CTest, DEBUG,
  996. " Error Line: " << data << " (matches: "
  997. << this->CustomErrorMatches[wrxCnt]
  998. << ")" << std::endl,
  999. this->Quiet);
  1000. break;
  1001. }
  1002. wrxCnt++;
  1003. }
  1004. // Error exceptions
  1005. wrxCnt = 0;
  1006. for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
  1007. if (rx.find(data)) {
  1008. errorLine = 0;
  1009. cmCTestOptionalLog(this->CTest, DEBUG,
  1010. " Not an error Line: "
  1011. << data << " (matches: "
  1012. << this->CustomErrorExceptions[wrxCnt] << ")"
  1013. << std::endl,
  1014. this->Quiet);
  1015. break;
  1016. }
  1017. wrxCnt++;
  1018. }
  1019. }
  1020. if (!this->WarningQuotaReached) {
  1021. // Warnings
  1022. int wrxCnt = 0;
  1023. for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
  1024. if (rx.find(data)) {
  1025. warningLine = 1;
  1026. cmCTestOptionalLog(this->CTest, DEBUG,
  1027. " Warning Line: "
  1028. << data << " (matches: "
  1029. << this->CustomWarningMatches[wrxCnt] << ")"
  1030. << std::endl,
  1031. this->Quiet);
  1032. break;
  1033. }
  1034. wrxCnt++;
  1035. }
  1036. wrxCnt = 0;
  1037. // Warning exceptions
  1038. for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
  1039. if (rx.find(data)) {
  1040. warningLine = 0;
  1041. cmCTestOptionalLog(this->CTest, DEBUG,
  1042. " Not a warning Line: "
  1043. << data << " (matches: "
  1044. << this->CustomWarningExceptions[wrxCnt] << ")"
  1045. << std::endl,
  1046. this->Quiet);
  1047. break;
  1048. }
  1049. wrxCnt++;
  1050. }
  1051. }
  1052. if (errorLine) {
  1053. return b_ERROR_LINE;
  1054. }
  1055. if (warningLine) {
  1056. return b_WARNING_LINE;
  1057. }
  1058. return b_REGULAR_LINE;
  1059. }