cmCTestBuildHandler.cxx 39 KB

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