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