cmCTestBuildHandler.cxx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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. cmSystemTools::ExpandListArgument(customWarningMatchers,
  228. this->ReallyCustomWarningMatches);
  229. }
  230. if (const char* customWarningExceptions =
  231. mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
  232. cmSystemTools::ExpandListArgument(customWarningExceptions,
  233. this->ReallyCustomWarningExceptions);
  234. }
  235. }
  236. std::string cmCTestBuildHandler::GetMakeCommand()
  237. {
  238. std::string makeCommand = this->CTest->GetCTestConfiguration("MakeCommand");
  239. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  240. "MakeCommand:" << makeCommand << "\n", this->Quiet);
  241. std::string configType = this->CTest->GetConfigType();
  242. if (configType.empty()) {
  243. configType =
  244. this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
  245. }
  246. if (configType.empty()) {
  247. configType = "Release";
  248. }
  249. cmSystemTools::ReplaceString(makeCommand, "${CTEST_CONFIGURATION_TYPE}",
  250. configType.c_str());
  251. return makeCommand;
  252. }
  253. // clearly it would be nice if this were broken up into a few smaller
  254. // functions and commented...
  255. int cmCTestBuildHandler::ProcessHandler()
  256. {
  257. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl,
  258. this->Quiet);
  259. // do we have time for this
  260. if (this->CTest->GetRemainingTimeAllowed() < std::chrono::minutes(2)) {
  261. return 0;
  262. }
  263. int entry;
  264. for (entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString;
  265. ++entry) {
  266. cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
  267. if (r.RegularExpression.compile(
  268. cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
  269. r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
  270. r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
  271. this->ErrorWarningFileLineRegex.push_back(std::move(r));
  272. } else {
  273. cmCTestLog(
  274. this->CTest, ERROR_MESSAGE,
  275. "Problem Compiling regular expression: "
  276. << cmCTestWarningErrorFileLine[entry].RegularExpressionString
  277. << std::endl);
  278. }
  279. }
  280. // Determine build command and build directory
  281. std::string makeCommand = this->GetMakeCommand();
  282. if (makeCommand.empty()) {
  283. cmCTestLog(this->CTest, ERROR_MESSAGE,
  284. "Cannot find MakeCommand key in the DartConfiguration.tcl"
  285. << std::endl);
  286. return -1;
  287. }
  288. const std::string& buildDirectory =
  289. this->CTest->GetCTestConfiguration("BuildDirectory");
  290. if (buildDirectory.empty()) {
  291. cmCTestLog(this->CTest, ERROR_MESSAGE,
  292. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  293. << std::endl);
  294. return -1;
  295. }
  296. std::string const& useLaunchers =
  297. this->CTest->GetCTestConfiguration("UseLaunchers");
  298. this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers);
  299. // Create a last build log
  300. cmGeneratedFileStream ofs;
  301. auto elapsed_time_start = std::chrono::steady_clock::now();
  302. if (!this->StartLogFile("Build", ofs)) {
  303. cmCTestLog(this->CTest, ERROR_MESSAGE,
  304. "Cannot create build log file" << std::endl);
  305. }
  306. // Create lists of regular expression strings for errors, error exceptions,
  307. // warnings and warning exceptions.
  308. std::vector<std::string>::size_type cc;
  309. for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
  310. this->CustomErrorMatches.emplace_back(cmCTestErrorMatches[cc]);
  311. }
  312. for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
  313. this->CustomErrorExceptions.emplace_back(cmCTestErrorExceptions[cc]);
  314. }
  315. for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
  316. this->CustomWarningMatches.emplace_back(cmCTestWarningMatches[cc]);
  317. }
  318. for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
  319. this->CustomWarningExceptions.emplace_back(cmCTestWarningExceptions[cc]);
  320. }
  321. // Pre-compile regular expressions objects for all regular expressions
  322. #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
  323. do { \
  324. regexes.clear(); \
  325. cmCTestOptionalLog(this->CTest, DEBUG, \
  326. this << "Add " #regexes << std::endl, this->Quiet); \
  327. for (std::string const& s : (strings)) { \
  328. cmCTestOptionalLog(this->CTest, DEBUG, \
  329. "Add " #strings ": " << s << std::endl, \
  330. this->Quiet); \
  331. (regexes).emplace_back(s); \
  332. } \
  333. } while (false)
  334. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
  335. this->ErrorMatchRegex);
  336. cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
  337. this->ErrorExceptionRegex);
  338. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
  339. this->WarningMatchRegex);
  340. cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
  341. this->WarningExceptionRegex);
  342. // Determine source and binary tree substitutions to simplify the output.
  343. this->SimplifySourceDir.clear();
  344. this->SimplifyBuildDir.clear();
  345. if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
  346. std::string srcdir =
  347. this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
  348. for (cc = srcdir.size() - 2; cc > 0; cc--) {
  349. if (srcdir[cc] == '/') {
  350. srcdir = srcdir.substr(0, cc + 1);
  351. break;
  352. }
  353. }
  354. this->SimplifySourceDir = srcdir;
  355. }
  356. if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
  357. std::string bindir =
  358. this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
  359. for (cc = bindir.size() - 2; cc > 0; cc--) {
  360. if (bindir[cc] == '/') {
  361. bindir = bindir.substr(0, cc + 1);
  362. break;
  363. }
  364. }
  365. this->SimplifyBuildDir = bindir;
  366. }
  367. // Ok, let's do the build
  368. // Remember start build time
  369. this->StartBuild = this->CTest->CurrentTime();
  370. this->StartBuildTime = std::chrono::system_clock::now();
  371. int retVal = 0;
  372. int res = cmsysProcess_State_Exited;
  373. if (!this->CTest->GetShowOnly()) {
  374. res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0,
  375. ofs);
  376. } else {
  377. cmCTestOptionalLog(this->CTest, DEBUG,
  378. "Build with command: " << makeCommand << std::endl,
  379. this->Quiet);
  380. }
  381. // Remember end build time and calculate elapsed time
  382. this->EndBuild = this->CTest->CurrentTime();
  383. this->EndBuildTime = std::chrono::system_clock::now();
  384. auto elapsed_build_time =
  385. std::chrono::steady_clock::now() - elapsed_time_start;
  386. // Cleanups strings in the errors and warnings list.
  387. if (!this->SimplifySourceDir.empty()) {
  388. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  389. cmSystemTools::ReplaceString(evit.Text, this->SimplifySourceDir.c_str(),
  390. "/.../");
  391. cmSystemTools::ReplaceString(evit.PreContext,
  392. this->SimplifySourceDir.c_str(), "/.../");
  393. cmSystemTools::ReplaceString(evit.PostContext,
  394. this->SimplifySourceDir.c_str(), "/.../");
  395. }
  396. }
  397. if (!this->SimplifyBuildDir.empty()) {
  398. for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
  399. cmSystemTools::ReplaceString(evit.Text, this->SimplifyBuildDir.c_str(),
  400. "/.../");
  401. cmSystemTools::ReplaceString(evit.PreContext,
  402. this->SimplifyBuildDir.c_str(), "/.../");
  403. cmSystemTools::ReplaceString(evit.PostContext,
  404. this->SimplifyBuildDir.c_str(), "/.../");
  405. }
  406. }
  407. // Generate XML output
  408. cmGeneratedFileStream xofs;
  409. if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
  410. cmCTestLog(this->CTest, ERROR_MESSAGE,
  411. "Cannot create build XML file" << std::endl);
  412. return -1;
  413. }
  414. cmXMLWriter xml(xofs);
  415. this->GenerateXMLHeader(xml);
  416. if (this->UseCTestLaunch) {
  417. this->GenerateXMLLaunched(xml);
  418. } else {
  419. this->GenerateXMLLogScraped(xml);
  420. }
  421. this->GenerateXMLFooter(xml, elapsed_build_time);
  422. if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
  423. cmCTestLog(this->CTest, ERROR_MESSAGE,
  424. "Error(s) when building project" << std::endl);
  425. }
  426. // Display message about number of errors and warnings
  427. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  428. " " << this->TotalErrors
  429. << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
  430. << " Compiler errors" << std::endl);
  431. cmCTestLog(
  432. this->CTest, HANDLER_OUTPUT,
  433. " " << this->TotalWarnings
  434. << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
  435. << " Compiler warnings" << std::endl);
  436. return retVal;
  437. }
  438. void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
  439. {
  440. this->CTest->StartXML(xml, this->AppendXML);
  441. this->CTest->GenerateSubprojectsOutput(xml);
  442. xml.StartElement("Build");
  443. xml.Element("StartDateTime", this->StartBuild);
  444. xml.Element("StartBuildTime", this->StartBuildTime);
  445. xml.Element("BuildCommand", this->GetMakeCommand());
  446. }
  447. class cmCTestBuildHandler::FragmentCompare
  448. {
  449. public:
  450. FragmentCompare(cmFileTimeCache* ftc)
  451. : FTC(ftc)
  452. {
  453. }
  454. FragmentCompare() = default;
  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->Compare(l, r, &result) && result != 0) {
  461. return result < 0;
  462. }
  463. return l < r;
  464. }
  465. private:
  466. cmFileTimeCache* FTC = nullptr;
  467. };
  468. void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
  469. {
  470. if (this->CTestLaunchDir.empty()) {
  471. return;
  472. }
  473. // Sort XML fragments in chronological order.
  474. cmFileTimeCache ftc;
  475. FragmentCompare fragmentCompare(&ftc);
  476. typedef std::set<std::string, FragmentCompare> Fragments;
  477. Fragments fragments(fragmentCompare);
  478. // only report the first 50 warnings and first 50 errors
  479. int numErrorsAllowed = this->MaxErrors;
  480. int numWarningsAllowed = this->MaxWarnings;
  481. // Identify fragments on disk.
  482. cmsys::Directory launchDir;
  483. launchDir.Load(this->CTestLaunchDir);
  484. unsigned long n = launchDir.GetNumberOfFiles();
  485. for (unsigned long i = 0; i < n; ++i) {
  486. const char* fname = launchDir.GetFile(i);
  487. if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
  488. numErrorsAllowed--;
  489. fragments.insert(this->CTestLaunchDir + "/" + fname);
  490. ++this->TotalErrors;
  491. } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
  492. numWarningsAllowed--;
  493. fragments.insert(this->CTestLaunchDir + "/" + fname);
  494. ++this->TotalWarnings;
  495. }
  496. }
  497. // Copy the fragments into the final XML file.
  498. for (std::string const& f : fragments) {
  499. xml.FragmentFile(f.c_str());
  500. }
  501. }
  502. void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
  503. {
  504. std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
  505. std::vector<cmCTestBuildErrorWarning>::iterator it;
  506. // only report the first 50 warnings and first 50 errors
  507. int numErrorsAllowed = this->MaxErrors;
  508. int numWarningsAllowed = this->MaxWarnings;
  509. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  510. // make sure the source dir is in the correct case on windows
  511. // via a call to collapse full path.
  512. srcdir = cmSystemTools::CollapseFullPath(srcdir);
  513. srcdir += "/";
  514. for (it = ew.begin();
  515. it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
  516. cmCTestBuildErrorWarning* cm = &(*it);
  517. if ((cm->Error && numErrorsAllowed) ||
  518. (!cm->Error && numWarningsAllowed)) {
  519. if (cm->Error) {
  520. numErrorsAllowed--;
  521. } else {
  522. numWarningsAllowed--;
  523. }
  524. xml.StartElement(cm->Error ? "Error" : "Warning");
  525. xml.Element("BuildLogLine", cm->LogLine);
  526. xml.Element("Text", cm->Text);
  527. for (cmCTestCompileErrorWarningRex& rit :
  528. this->ErrorWarningFileLineRegex) {
  529. cmsys::RegularExpression* re = &rit.RegularExpression;
  530. if (re->find(cm->Text)) {
  531. cm->SourceFile = re->match(rit.FileIndex);
  532. // At this point we need to make this->SourceFile relative to
  533. // the source root of the project, so cvs links will work
  534. cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
  535. if (cm->SourceFile.find("/.../") != std::string::npos) {
  536. cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
  537. std::string::size_type p = cm->SourceFile.find('/');
  538. if (p != std::string::npos) {
  539. cm->SourceFile =
  540. cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
  541. }
  542. } else {
  543. // make sure it is a full path with the correct case
  544. cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
  545. cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
  546. }
  547. cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
  548. break;
  549. }
  550. }
  551. if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
  552. if (!cm->SourceFile.empty()) {
  553. xml.Element("SourceFile", cm->SourceFile);
  554. }
  555. if (!cm->SourceFileTail.empty()) {
  556. xml.Element("SourceFileTail", cm->SourceFileTail);
  557. }
  558. if (cm->LineNumber >= 0) {
  559. xml.Element("SourceLineNumber", cm->LineNumber);
  560. }
  561. }
  562. xml.Element("PreContext", cm->PreContext);
  563. xml.StartElement("PostContext");
  564. xml.Content(cm->PostContext);
  565. // is this the last warning or error, if so notify
  566. if ((cm->Error && !numErrorsAllowed) ||
  567. (!cm->Error && !numWarningsAllowed)) {
  568. xml.Content("\nThe maximum number of reported warnings or errors "
  569. "has been reached!!!\n");
  570. }
  571. xml.EndElement(); // PostContext
  572. xml.Element("RepeatCount", "0");
  573. xml.EndElement(); // "Error" / "Warning"
  574. }
  575. }
  576. }
  577. void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
  578. cmDuration elapsed_build_time)
  579. {
  580. xml.StartElement("Log");
  581. xml.Attribute("Encoding", "base64");
  582. xml.Attribute("Compression", "bin/gzip");
  583. xml.EndElement(); // Log
  584. xml.Element("EndDateTime", this->EndBuild);
  585. xml.Element("EndBuildTime", this->EndBuildTime);
  586. xml.Element(
  587. "ElapsedMinutes",
  588. std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
  589. .count());
  590. xml.EndElement(); // Build
  591. this->CTest->EndXML(xml);
  592. }
  593. bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
  594. {
  595. // error-{hash}.xml
  596. return (cmHasLiteralPrefix(fname, "error-") &&
  597. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  598. }
  599. bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
  600. {
  601. // warning-{hash}.xml
  602. return (cmHasLiteralPrefix(fname, "warning-") &&
  603. strcmp(fname + strlen(fname) - 4, ".xml") == 0);
  604. }
  605. //######################################################################
  606. //######################################################################
  607. //######################################################################
  608. //######################################################################
  609. class cmCTestBuildHandler::LaunchHelper
  610. {
  611. public:
  612. LaunchHelper(cmCTestBuildHandler* handler);
  613. ~LaunchHelper();
  614. LaunchHelper(const LaunchHelper&) = delete;
  615. LaunchHelper& operator=(const LaunchHelper&) = delete;
  616. private:
  617. cmCTestBuildHandler* Handler;
  618. cmCTest* CTest;
  619. void WriteLauncherConfig();
  620. void WriteScrapeMatchers(const char* purpose,
  621. std::vector<std::string> const& matchers);
  622. };
  623. cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
  624. : Handler(handler)
  625. , CTest(handler->CTest)
  626. {
  627. std::string tag = this->CTest->GetCurrentTag();
  628. if (tag.empty()) {
  629. // This is not for a dashboard submission, so there is no XML.
  630. // Skip enabling the launchers.
  631. this->Handler->UseCTestLaunch = false;
  632. } else {
  633. // Compute a directory in which to store launcher fragments.
  634. std::string& launchDir = this->Handler->CTestLaunchDir;
  635. launchDir = this->CTest->GetBinaryDir();
  636. launchDir += "/Testing/";
  637. launchDir += tag;
  638. launchDir += "/Build";
  639. // Clean out any existing launcher fragments.
  640. cmSystemTools::RemoveADirectory(launchDir);
  641. if (this->Handler->UseCTestLaunch) {
  642. // Enable launcher fragments.
  643. cmSystemTools::MakeDirectory(launchDir);
  644. this->WriteLauncherConfig();
  645. std::string launchEnv = "CTEST_LAUNCH_LOGS=";
  646. launchEnv += launchDir;
  647. cmSystemTools::PutEnv(launchEnv);
  648. }
  649. }
  650. // If not using launchers, make sure they passthru.
  651. if (!this->Handler->UseCTestLaunch) {
  652. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  653. }
  654. }
  655. cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
  656. {
  657. if (this->Handler->UseCTestLaunch) {
  658. cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
  659. }
  660. }
  661. void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
  662. {
  663. this->WriteScrapeMatchers("Warning",
  664. this->Handler->ReallyCustomWarningMatches);
  665. this->WriteScrapeMatchers("WarningSuppress",
  666. this->Handler->ReallyCustomWarningExceptions);
  667. // Give some testing configuration information to the launcher.
  668. std::string fname = this->Handler->CTestLaunchDir;
  669. fname += "/CTestLaunchConfig.cmake";
  670. cmGeneratedFileStream fout(fname);
  671. std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
  672. fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
  673. }
  674. void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
  675. const char* purpose, std::vector<std::string> const& matchers)
  676. {
  677. if (matchers.empty()) {
  678. return;
  679. }
  680. std::string fname = this->Handler->CTestLaunchDir;
  681. fname += "/Custom";
  682. fname += purpose;
  683. fname += ".txt";
  684. cmGeneratedFileStream fout(fname);
  685. for (std::string const& m : matchers) {
  686. fout << m << "\n";
  687. }
  688. }
  689. int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
  690. int* retVal, const char* dir,
  691. int timeout, std::ostream& ofs,
  692. Encoding encoding)
  693. {
  694. // First generate the command and arguments
  695. std::vector<std::string> args = cmSystemTools::ParseArguments(command);
  696. if (args.empty()) {
  697. return false;
  698. }
  699. std::vector<const char*> argv;
  700. argv.reserve(args.size() + 1);
  701. for (std::string const& arg : args) {
  702. argv.push_back(arg.c_str());
  703. }
  704. argv.push_back(nullptr);
  705. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  706. "Run command:", this->Quiet);
  707. for (char const* arg : argv) {
  708. if (!arg) {
  709. break;
  710. }
  711. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  712. " \"" << arg << "\"", this->Quiet);
  713. }
  714. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
  715. this->Quiet);
  716. // Optionally use make rule launchers to record errors and warnings.
  717. LaunchHelper launchHelper(this);
  718. static_cast<void>(launchHelper);
  719. // Now create process object
  720. cmsysProcess* cp = cmsysProcess_New();
  721. cmsysProcess_SetCommand(cp, argv.data());
  722. cmsysProcess_SetWorkingDirectory(cp, dir);
  723. cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
  724. cmsysProcess_SetTimeout(cp, timeout);
  725. cmsysProcess_Execute(cp);
  726. // Initialize tick's
  727. std::string::size_type tick = 0;
  728. const std::string::size_type tick_len = 1024;
  729. char* data;
  730. int length;
  731. cmProcessOutput processOutput(encoding);
  732. std::string strdata;
  733. cmCTestOptionalLog(
  734. this->CTest, HANDLER_PROGRESS_OUTPUT,
  735. " Each symbol represents "
  736. << tick_len << " bytes of output." << std::endl
  737. << (this->UseCTestLaunch
  738. ? ""
  739. : " '!' represents an error and '*' a warning.\n")
  740. << " " << std::flush,
  741. this->Quiet);
  742. // Initialize building structures
  743. this->BuildProcessingQueue.clear();
  744. this->OutputLineCounter = 0;
  745. this->ErrorsAndWarnings.clear();
  746. this->TotalErrors = 0;
  747. this->TotalWarnings = 0;
  748. this->BuildOutputLogSize = 0;
  749. this->LastTickChar = '.';
  750. this->WarningQuotaReached = false;
  751. this->ErrorQuotaReached = false;
  752. // For every chunk of data
  753. int res;
  754. while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
  755. // Replace '\0' with '\n', since '\0' does not really make sense. This is
  756. // for Visual Studio output
  757. for (int cc = 0; cc < length; ++cc) {
  758. if (data[cc] == 0) {
  759. data[cc] = '\n';
  760. }
  761. }
  762. // Process the chunk of data
  763. if (res == cmsysProcess_Pipe_STDERR) {
  764. processOutput.DecodeText(data, length, strdata, 1);
  765. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  766. &this->BuildProcessingErrorQueue);
  767. } else {
  768. processOutput.DecodeText(data, length, strdata, 2);
  769. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  770. &this->BuildProcessingQueue);
  771. }
  772. }
  773. processOutput.DecodeText(std::string(), strdata, 1);
  774. if (!strdata.empty()) {
  775. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  776. &this->BuildProcessingErrorQueue);
  777. }
  778. processOutput.DecodeText(std::string(), strdata, 2);
  779. if (!strdata.empty()) {
  780. this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs,
  781. &this->BuildProcessingQueue);
  782. }
  783. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  784. &this->BuildProcessingQueue);
  785. this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
  786. &this->BuildProcessingErrorQueue);
  787. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  788. " Size of output: "
  789. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  790. << std::endl,
  791. this->Quiet);
  792. // Properly handle output of the build command
  793. cmsysProcess_WaitForExit(cp, nullptr);
  794. int result = cmsysProcess_GetState(cp);
  795. if (result == cmsysProcess_State_Exited) {
  796. if (retVal) {
  797. *retVal = cmsysProcess_GetExitValue(cp);
  798. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  799. "Command exited with the value: " << *retVal
  800. << std::endl,
  801. this->Quiet);
  802. // if a non zero return value
  803. if (*retVal) {
  804. // If there was an error running command, report that on the
  805. // dashboard.
  806. cmCTestBuildErrorWarning errorwarning;
  807. errorwarning.LogLine = 1;
  808. errorwarning.Text =
  809. "*** WARNING non-zero return value in ctest from: ";
  810. errorwarning.Text += argv[0];
  811. errorwarning.PreContext.clear();
  812. errorwarning.PostContext.clear();
  813. errorwarning.Error = false;
  814. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  815. this->TotalWarnings++;
  816. }
  817. }
  818. } else if (result == cmsysProcess_State_Exception) {
  819. if (retVal) {
  820. *retVal = cmsysProcess_GetExitException(cp);
  821. cmCTestOptionalLog(this->CTest, WARNING,
  822. "There was an exception: " << *retVal << std::endl,
  823. this->Quiet);
  824. }
  825. } else if (result == cmsysProcess_State_Expired) {
  826. cmCTestOptionalLog(this->CTest, WARNING,
  827. "There was a timeout" << std::endl, this->Quiet);
  828. } else if (result == cmsysProcess_State_Error) {
  829. // If there was an error running command, report that on the dashboard.
  830. cmCTestBuildErrorWarning errorwarning;
  831. errorwarning.LogLine = 1;
  832. errorwarning.Text = "*** ERROR executing: ";
  833. errorwarning.Text += cmsysProcess_GetErrorString(cp);
  834. errorwarning.PreContext.clear();
  835. errorwarning.PostContext.clear();
  836. errorwarning.Error = true;
  837. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  838. this->TotalErrors++;
  839. cmCTestLog(this->CTest, ERROR_MESSAGE,
  840. "There was an error: " << cmsysProcess_GetErrorString(cp)
  841. << std::endl);
  842. }
  843. cmsysProcess_Delete(cp);
  844. return result;
  845. }
  846. //######################################################################
  847. //######################################################################
  848. //######################################################################
  849. //######################################################################
  850. void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
  851. size_t& tick, size_t tick_len,
  852. std::ostream& ofs,
  853. t_BuildProcessingQueueType* queue)
  854. {
  855. const std::string::size_type tick_line_len = 50;
  856. const char* ptr;
  857. for (ptr = data; ptr < data + length; ptr++) {
  858. queue->push_back(*ptr);
  859. }
  860. this->BuildOutputLogSize += length;
  861. // until there are any lines left in the buffer
  862. while (true) {
  863. // Find the end of line
  864. t_BuildProcessingQueueType::iterator it;
  865. for (it = queue->begin(); it != queue->end(); ++it) {
  866. if (*it == '\n') {
  867. break;
  868. }
  869. }
  870. // Once certain number of errors or warnings reached, ignore future errors
  871. // or warnings.
  872. if (this->TotalWarnings >= this->MaxWarnings) {
  873. this->WarningQuotaReached = true;
  874. }
  875. if (this->TotalErrors >= this->MaxErrors) {
  876. this->ErrorQuotaReached = true;
  877. }
  878. // If the end of line was found
  879. if (it != queue->end()) {
  880. // Create a contiguous array for the line
  881. this->CurrentProcessingLine.clear();
  882. cmAppend(this->CurrentProcessingLine, queue->begin(), it);
  883. this->CurrentProcessingLine.push_back(0);
  884. const char* line = this->CurrentProcessingLine.data();
  885. // Process the line
  886. int lineType = this->ProcessSingleLine(line);
  887. // Erase the line from the queue
  888. queue->erase(queue->begin(), it + 1);
  889. // Depending on the line type, produce error or warning, or nothing
  890. cmCTestBuildErrorWarning errorwarning;
  891. bool found = false;
  892. switch (lineType) {
  893. case b_WARNING_LINE:
  894. this->LastTickChar = '*';
  895. errorwarning.Error = false;
  896. found = true;
  897. this->TotalWarnings++;
  898. break;
  899. case b_ERROR_LINE:
  900. this->LastTickChar = '!';
  901. errorwarning.Error = true;
  902. found = true;
  903. this->TotalErrors++;
  904. break;
  905. }
  906. if (found) {
  907. // This is an error or warning, so generate report
  908. errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
  909. errorwarning.Text = line;
  910. errorwarning.PreContext.clear();
  911. errorwarning.PostContext.clear();
  912. // Copy pre-context to report
  913. for (std::string const& pc : this->PreContext) {
  914. errorwarning.PreContext += pc + "\n";
  915. }
  916. this->PreContext.clear();
  917. // Store report
  918. this->ErrorsAndWarnings.push_back(std::move(errorwarning));
  919. this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
  920. this->PostContextCount = 0;
  921. } else {
  922. // This is not an error or warning.
  923. // So, figure out if this is a post-context line
  924. if (!this->ErrorsAndWarnings.empty() &&
  925. this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
  926. this->PostContextCount < this->MaxPostContext) {
  927. this->PostContextCount++;
  928. this->LastErrorOrWarning->PostContext += line;
  929. if (this->PostContextCount < this->MaxPostContext) {
  930. this->LastErrorOrWarning->PostContext += "\n";
  931. }
  932. } else {
  933. // Otherwise store pre-context for the next error
  934. this->PreContext.emplace_back(line);
  935. if (this->PreContext.size() > this->MaxPreContext) {
  936. this->PreContext.erase(this->PreContext.begin(),
  937. this->PreContext.end() -
  938. this->MaxPreContext);
  939. }
  940. }
  941. }
  942. this->OutputLineCounter++;
  943. } else {
  944. break;
  945. }
  946. }
  947. // Now that the buffer is processed, display missing ticks
  948. int tickDisplayed = false;
  949. while (this->BuildOutputLogSize > (tick * tick_len)) {
  950. tick++;
  951. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  952. this->LastTickChar, this->Quiet);
  953. tickDisplayed = true;
  954. if (tick % tick_line_len == 0 && tick > 0) {
  955. cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
  956. " Size: "
  957. << ((this->BuildOutputLogSize + 512) / 1024) << "K"
  958. << std::endl
  959. << " ",
  960. this->Quiet);
  961. }
  962. }
  963. if (tickDisplayed) {
  964. this->LastTickChar = '.';
  965. }
  966. // And if this is verbose output, display the content of the chunk
  967. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  968. cmCTestLogWrite(data, length));
  969. // Always store the chunk to the file
  970. ofs << cmCTestLogWrite(data, length);
  971. }
  972. int cmCTestBuildHandler::ProcessSingleLine(const char* data)
  973. {
  974. if (this->UseCTestLaunch) {
  975. // No log scraping when using launchers.
  976. return b_REGULAR_LINE;
  977. }
  978. cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
  979. this->Quiet);
  980. int warningLine = 0;
  981. int errorLine = 0;
  982. // Check for regular expressions
  983. if (!this->ErrorQuotaReached) {
  984. // Errors
  985. int wrxCnt = 0;
  986. for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
  987. if (rx.find(data)) {
  988. errorLine = 1;
  989. cmCTestOptionalLog(this->CTest, DEBUG,
  990. " Error Line: " << data << " (matches: "
  991. << this->CustomErrorMatches[wrxCnt]
  992. << ")" << std::endl,
  993. this->Quiet);
  994. break;
  995. }
  996. wrxCnt++;
  997. }
  998. // Error exceptions
  999. wrxCnt = 0;
  1000. for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
  1001. if (rx.find(data)) {
  1002. errorLine = 0;
  1003. cmCTestOptionalLog(this->CTest, DEBUG,
  1004. " Not an error Line: "
  1005. << data << " (matches: "
  1006. << this->CustomErrorExceptions[wrxCnt] << ")"
  1007. << std::endl,
  1008. this->Quiet);
  1009. break;
  1010. }
  1011. wrxCnt++;
  1012. }
  1013. }
  1014. if (!this->WarningQuotaReached) {
  1015. // Warnings
  1016. int wrxCnt = 0;
  1017. for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
  1018. if (rx.find(data)) {
  1019. warningLine = 1;
  1020. cmCTestOptionalLog(this->CTest, DEBUG,
  1021. " Warning Line: "
  1022. << data << " (matches: "
  1023. << this->CustomWarningMatches[wrxCnt] << ")"
  1024. << std::endl,
  1025. this->Quiet);
  1026. break;
  1027. }
  1028. wrxCnt++;
  1029. }
  1030. wrxCnt = 0;
  1031. // Warning exceptions
  1032. for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
  1033. if (rx.find(data)) {
  1034. warningLine = 0;
  1035. cmCTestOptionalLog(this->CTest, DEBUG,
  1036. " Not a warning Line: "
  1037. << data << " (matches: "
  1038. << this->CustomWarningExceptions[wrxCnt] << ")"
  1039. << std::endl,
  1040. this->Quiet);
  1041. break;
  1042. }
  1043. wrxCnt++;
  1044. }
  1045. }
  1046. if (errorLine) {
  1047. return b_ERROR_LINE;
  1048. }
  1049. if (warningLine) {
  1050. return b_WARNING_LINE;
  1051. }
  1052. return b_REGULAR_LINE;
  1053. }