cmCTestBuildHandler.cxx 39 KB

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