cmCTestBuildHandler.cxx 39 KB

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