2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2004-09-07 18:37:39 +04:00
|
|
|
#include "cmCTestBuildHandler.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2004-09-07 18:37:39 +04:00
|
|
|
#include "cmCTest.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmFileTimeComparison.h"
|
2005-01-27 18:15:01 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmMakefile.h"
|
2016-08-24 23:01:40 +03:00
|
|
|
#include "cmSystemTools.h"
|
2015-05-24 22:36:12 +03:00
|
|
|
#include "cmXMLWriter.h"
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
#include <cmsys/Directory.hxx>
|
2014-01-04 09:47:13 +04:00
|
|
|
#include <cmsys/FStream.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/Process.h>
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <set>
|
2006-03-09 19:17:10 +03:00
|
|
|
#include <stdlib.h>
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <string.h>
|
2004-09-07 18:37:39 +04:00
|
|
|
|
|
|
|
static const char* cmCTestErrorMatches[] = {
|
|
|
|
"^[Bb]us [Ee]rror",
|
|
|
|
"^[Ss]egmentation [Vv]iolation",
|
|
|
|
"^[Ss]egmentation [Ff]ault",
|
2011-01-05 22:14:04 +03:00
|
|
|
":.*[Pp]ermission [Dd]enied",
|
2004-09-07 18:37:39 +04:00
|
|
|
"([^ :]+):([0-9]+): ([^ \\t])",
|
|
|
|
"([^:]+): error[ \\t]*[0-9]+[ \\t]*:",
|
|
|
|
"^Error ([0-9]+):",
|
|
|
|
"^Fatal",
|
|
|
|
"^Error: ",
|
|
|
|
"^Error ",
|
|
|
|
"[0-9] ERROR: ",
|
|
|
|
"^\"[^\"]+\", line [0-9]+: [^Ww]",
|
|
|
|
"^cc[^C]*CC: ERROR File = ([^,]+), Line = ([0-9]+)",
|
|
|
|
"^ld([^:])*:([ \\t])*ERROR([^:])*:",
|
|
|
|
"^ild:([ \\t])*\\(undefined symbol\\)",
|
|
|
|
"([^ :]+) : (error|fatal error|catastrophic error)",
|
|
|
|
"([^:]+): (Error:|error|undefined reference|multiply defined)",
|
2011-12-15 18:30:33 +04:00
|
|
|
"([^:]+)\\(([^\\)]+)\\) ?: (error|fatal error|catastrophic error)",
|
2004-09-07 18:37:39 +04:00
|
|
|
"^fatal error C[0-9]+:",
|
|
|
|
": syntax error ",
|
|
|
|
"^collect2: ld returned 1 exit status",
|
2008-03-19 18:18:40 +03:00
|
|
|
"ld terminated with signal",
|
2011-01-05 22:14:04 +03:00
|
|
|
"Unsatisfied symbol",
|
2004-09-07 18:37:39 +04:00
|
|
|
"^Unresolved:",
|
2011-01-05 22:14:04 +03:00
|
|
|
"Undefined symbol",
|
2004-09-07 18:37:39 +04:00
|
|
|
"^Undefined[ \\t]+first referenced",
|
2010-07-02 21:22:30 +04:00
|
|
|
"^CMake Error.*:",
|
2004-09-07 18:37:39 +04:00
|
|
|
":[ \\t]cannot find",
|
|
|
|
":[ \\t]can't find",
|
2015-05-27 18:23:15 +03:00
|
|
|
": \\*\\*\\* No rule to make target [`'].*\\'. Stop",
|
2007-03-20 21:11:32 +03:00
|
|
|
": \\*\\*\\* No targets specified and no makefile found",
|
2004-09-07 18:37:39 +04:00
|
|
|
": Invalid loader fixup for symbol",
|
2005-07-22 16:39:56 +04:00
|
|
|
": Invalid fixups exist",
|
|
|
|
": Can't find library for",
|
2004-09-07 18:37:39 +04:00
|
|
|
": internal link edit command failed",
|
2015-05-27 18:23:15 +03:00
|
|
|
": Unrecognized option [`'].*\\'",
|
2006-08-23 00:07:20 +04:00
|
|
|
"\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([^WI]\\)",
|
2004-09-07 18:37:39 +04:00
|
|
|
"ld: 0706-006 Cannot find or open library file: -l ",
|
|
|
|
"ild: \\(argument error\\) can't find library argument ::",
|
|
|
|
"^could not be found and will not be loaded.",
|
|
|
|
"s:616 string too big",
|
|
|
|
"make: Fatal error: ",
|
|
|
|
"ld: 0711-993 Error occurred while writing to the output file:",
|
2004-11-12 01:40:08 +03:00
|
|
|
"ld: fatal: ",
|
2005-08-17 22:16:17 +04:00
|
|
|
"final link failed:",
|
2004-09-07 18:37:39 +04:00
|
|
|
"make: \\*\\*\\*.*Error",
|
2005-11-18 18:40:31 +03:00
|
|
|
"make\\[.*\\]: \\*\\*\\*.*Error",
|
2005-01-28 18:12:28 +03:00
|
|
|
"\\*\\*\\* Error code",
|
2005-08-03 22:16:13 +04:00
|
|
|
"nternal error:",
|
2005-06-01 23:59:22 +04:00
|
|
|
"Makefile:[0-9]+: \\*\\*\\* .* Stop\\.",
|
2006-03-23 17:56:32 +03:00
|
|
|
": No such file or directory",
|
|
|
|
": Invalid argument",
|
2007-03-16 23:04:31 +03:00
|
|
|
"^The project cannot be built\\.",
|
2011-03-18 11:38:34 +03:00
|
|
|
"^\\[ERROR\\]",
|
2012-03-09 03:32:12 +04:00
|
|
|
"^Command .* failed with exit code",
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR
|
2004-09-07 18:37:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* cmCTestErrorExceptions[] = {
|
|
|
|
"instantiated from ",
|
|
|
|
"candidates are:",
|
|
|
|
": warning",
|
2005-07-22 16:39:56 +04:00
|
|
|
": \\(Warning\\)",
|
2006-10-12 22:47:40 +04:00
|
|
|
": note",
|
2016-05-11 16:55:58 +03:00
|
|
|
"Note:",
|
2004-09-07 18:37:39 +04:00
|
|
|
"makefile:",
|
|
|
|
"Makefile:",
|
|
|
|
":[ \\t]+Where:",
|
|
|
|
"([^ :]+):([0-9]+): Warning",
|
2005-10-13 18:30:42 +04:00
|
|
|
"------ Build started: .* ------",
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR
|
2004-09-07 18:37:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* cmCTestWarningMatches[] = {
|
|
|
|
"([^ :]+):([0-9]+): warning:",
|
2006-10-12 22:47:40 +04:00
|
|
|
"([^ :]+):([0-9]+): note:",
|
2004-09-07 18:37:39 +04:00
|
|
|
"^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)",
|
|
|
|
"^ld([^:])*:([ \\t])*WARNING([^:])*:",
|
|
|
|
"([^:]+): warning ([0-9]+):",
|
2006-01-27 21:46:33 +03:00
|
|
|
"^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)",
|
2004-09-07 18:37:39 +04:00
|
|
|
"([^:]+): warning[ \\t]*[0-9]+[ \\t]*:",
|
2006-01-27 21:46:33 +03:00
|
|
|
"^(Warning|Warnung) ([0-9]+):",
|
2011-03-18 11:38:34 +03:00
|
|
|
"^(Warning|Warnung)[ :]",
|
2004-09-07 18:37:39 +04:00
|
|
|
"WARNING: ",
|
|
|
|
"([^ :]+) : warning",
|
|
|
|
"([^:]+): warning",
|
2006-08-23 00:07:20 +04:00
|
|
|
"\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([WI]\\)",
|
2004-09-07 18:37:39 +04:00
|
|
|
"^cxx: Warning:",
|
|
|
|
".*file: .* has no symbols",
|
2006-01-27 21:46:33 +03:00
|
|
|
"([^ :]+):([0-9]+): (Warning|Warnung)",
|
2004-09-17 01:13:59 +04:00
|
|
|
"\\([0-9]*\\): remark #[0-9]*",
|
2004-10-21 21:34:55 +04:00
|
|
|
"\".*\", line [0-9]+: remark\\([0-9]*\\):",
|
2004-10-26 18:24:31 +04:00
|
|
|
"cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*",
|
2010-07-02 21:22:30 +04:00
|
|
|
"^CMake Warning.*:",
|
2011-03-18 11:38:34 +03:00
|
|
|
"^\\[WARNING\\]",
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR
|
2004-09-07 18:37:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* cmCTestWarningExceptions[] = {
|
2006-03-09 19:17:10 +03:00
|
|
|
"/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
|
|
|
|
"/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
|
|
|
|
"/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
|
2004-09-07 18:37:39 +04:00
|
|
|
"WARNING 84 :",
|
|
|
|
"WARNING 47 :",
|
|
|
|
"makefile:",
|
|
|
|
"Makefile:",
|
|
|
|
"warning: Clock skew detected. Your build may be incomplete.",
|
|
|
|
"/usr/openwin/include/GL/[^:]+:",
|
|
|
|
"bind_at_load",
|
|
|
|
"XrmQGetResource",
|
|
|
|
"IceFlush",
|
|
|
|
"warning LNK4089: all references to [^ \\t]+ discarded by .OPT:REF",
|
|
|
|
"ld32: WARNING 85: definition of dataKey in",
|
|
|
|
"cc: warning 422: Unknown option \"\\+b",
|
|
|
|
"_with_warning_C",
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR
|
2004-09-07 18:37:39 +04:00
|
|
|
};
|
|
|
|
|
2004-10-01 02:06:29 +04:00
|
|
|
struct cmCTestBuildCompileErrorWarningRex
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
const char* RegularExpressionString;
|
|
|
|
int FileIndex;
|
|
|
|
int LineIndex;
|
2004-10-01 02:06:29 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = {
|
|
|
|
{ "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
|
|
|
|
{ "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
|
|
|
|
{ "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
|
|
|
|
{ "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
|
|
|
|
{ "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
|
|
|
|
{ "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
|
|
|
|
{ "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
|
2016-06-27 23:44:16 +03:00
|
|
|
{ CM_NULLPTR, 0, 0 }
|
2004-10-01 00:20:23 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
cmCTestBuildHandler::cmCTestBuildHandler()
|
|
|
|
{
|
2010-07-02 21:22:30 +04:00
|
|
|
this->MaxPreContext = 10;
|
|
|
|
this->MaxPostContext = 10;
|
2005-06-02 19:47:10 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MaxErrors = 50;
|
|
|
|
this->MaxWarnings = 50;
|
2005-06-02 19:47:10 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->LastErrorOrWarning = this->ErrorsAndWarnings.end();
|
2005-06-06 17:23:45 +04:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
this->UseCTestLaunch = false;
|
2004-10-01 00:20:23 +04:00
|
|
|
}
|
|
|
|
|
2005-06-17 21:04:56 +04:00
|
|
|
void cmCTestBuildHandler::Initialize()
|
|
|
|
{
|
2005-06-23 21:04:18 +04:00
|
|
|
this->Superclass::Initialize();
|
2006-03-10 23:03:09 +03:00
|
|
|
this->StartBuild = "";
|
|
|
|
this->EndBuild = "";
|
|
|
|
this->CustomErrorMatches.clear();
|
|
|
|
this->CustomErrorExceptions.clear();
|
|
|
|
this->CustomWarningMatches.clear();
|
|
|
|
this->CustomWarningExceptions.clear();
|
2009-02-11 23:18:08 +03:00
|
|
|
this->ReallyCustomWarningMatches.clear();
|
|
|
|
this->ReallyCustomWarningExceptions.clear();
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ErrorWarningFileLineRegex.clear();
|
|
|
|
|
|
|
|
this->ErrorMatchRegex.clear();
|
|
|
|
this->ErrorExceptionRegex.clear();
|
|
|
|
this->WarningMatchRegex.clear();
|
|
|
|
this->WarningExceptionRegex.clear();
|
|
|
|
this->BuildProcessingQueue.clear();
|
|
|
|
this->BuildProcessingErrorQueue.clear();
|
|
|
|
this->BuildOutputLogSize = 0;
|
|
|
|
this->CurrentProcessingLine.clear();
|
|
|
|
|
|
|
|
this->SimplifySourceDir = "";
|
|
|
|
this->SimplifyBuildDir = "";
|
|
|
|
this->OutputLineCounter = 0;
|
|
|
|
this->ErrorsAndWarnings.clear();
|
|
|
|
this->LastErrorOrWarning = this->ErrorsAndWarnings.end();
|
|
|
|
this->PostContextCount = 0;
|
2010-07-02 21:22:30 +04:00
|
|
|
this->MaxPreContext = 10;
|
|
|
|
this->MaxPostContext = 10;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->PreContext.clear();
|
|
|
|
|
|
|
|
this->TotalErrors = 0;
|
|
|
|
this->TotalWarnings = 0;
|
|
|
|
this->LastTickChar = 0;
|
|
|
|
|
|
|
|
this->ErrorQuotaReached = false;
|
|
|
|
this->WarningQuotaReached = false;
|
|
|
|
|
|
|
|
this->MaxErrors = 50;
|
|
|
|
this->MaxWarnings = 50;
|
2009-02-11 23:18:08 +03:00
|
|
|
|
|
|
|
this->UseCTestLaunch = false;
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf)
|
2004-09-07 18:37:39 +04:00
|
|
|
{
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CustomErrorMatches);
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CustomErrorExceptions);
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CustomWarningMatches);
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CustomWarningExceptions);
|
|
|
|
this->CTest->PopulateCustomInteger(
|
|
|
|
mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", this->MaxErrors);
|
|
|
|
this->CTest->PopulateCustomInteger(
|
|
|
|
mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings);
|
2009-02-11 23:18:08 +03:00
|
|
|
|
2010-07-02 21:22:30 +04:00
|
|
|
int n = -1;
|
|
|
|
this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (n != -1) {
|
2010-07-02 21:22:30 +04:00
|
|
|
this->MaxPreContext = static_cast<size_t>(n);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-07-02 21:22:30 +04:00
|
|
|
|
|
|
|
n = -1;
|
|
|
|
this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (n != -1) {
|
2010-07-02 21:22:30 +04:00
|
|
|
this->MaxPostContext = static_cast<size_t>(n);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-07-02 21:22:30 +04:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
// Record the user-specified custom warning rules.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* customWarningMatchers =
|
|
|
|
mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) {
|
2009-02-11 23:18:08 +03:00
|
|
|
cmSystemTools::ExpandListArgument(customWarningMatchers,
|
|
|
|
this->ReallyCustomWarningMatches);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* customWarningExceptions =
|
|
|
|
mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
|
2009-02-11 23:18:08 +03:00
|
|
|
cmSystemTools::ExpandListArgument(customWarningExceptions,
|
|
|
|
this->ReallyCustomWarningExceptions);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
}
|
|
|
|
|
2009-12-04 20:09:01 +03:00
|
|
|
std::string cmCTestBuildHandler::GetMakeCommand()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string makeCommand = this->CTest->GetCTestConfiguration("MakeCommand");
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"MakeCommand:" << makeCommand << "\n", this->Quiet);
|
2009-12-04 20:09:01 +03:00
|
|
|
|
|
|
|
std::string configType = this->CTest->GetConfigType();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configType == "") {
|
|
|
|
configType =
|
|
|
|
this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
|
|
|
|
}
|
|
|
|
if (configType == "") {
|
2009-12-04 20:09:01 +03:00
|
|
|
configType = "Release";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-04 20:09:01 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ReplaceString(makeCommand, "${CTEST_CONFIGURATION_TYPE}",
|
|
|
|
configType.c_str());
|
2009-12-04 20:09:01 +03:00
|
|
|
|
|
|
|
return makeCommand;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// clearly it would be nice if this were broken up into a few smaller
|
|
|
|
// functions and commented...
|
2005-01-27 23:54:47 +03:00
|
|
|
int cmCTestBuildHandler::ProcessHandler()
|
2004-09-07 18:37:39 +04:00
|
|
|
{
|
2015-02-17 21:41:40 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
2006-10-19 18:45:19 +04:00
|
|
|
// do we have time for this
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CTest->GetRemainingTimeAllowed() < 120) {
|
2006-10-19 18:45:19 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-19 18:45:19 +04:00
|
|
|
|
2005-07-03 06:31:30 +04:00
|
|
|
int entry;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString;
|
|
|
|
++entry) {
|
2005-07-03 06:31:30 +04:00
|
|
|
cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (r.RegularExpression.compile(
|
|
|
|
cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
|
|
|
|
r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
|
|
|
|
this->ErrorWarningFileLineRegex.push_back(r);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmCTestLog(
|
|
|
|
this->CTest, ERROR_MESSAGE, "Problem Compiling regular expression: "
|
|
|
|
<< cmCTestWarningErrorFileLine[entry].RegularExpressionString
|
|
|
|
<< std::endl);
|
2005-07-03 06:31:30 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-03 06:31:30 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Determine build command and build directory
|
2009-12-04 20:09:01 +03:00
|
|
|
std::string makeCommand = this->GetMakeCommand();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (makeCommand.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find MakeCommand key in the DartConfiguration.tcl"
|
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-04 20:09:01 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& buildDirectory =
|
|
|
|
this->CTest->GetCTestConfiguration("BuildDirectory");
|
|
|
|
if (buildDirectory.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
|
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
std::string const& useLaunchers =
|
|
|
|
this->CTest->GetCTestConfiguration("UseLaunchers");
|
|
|
|
this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers.c_str());
|
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Create a last build log
|
2005-01-27 18:15:01 +03:00
|
|
|
cmGeneratedFileStream ofs;
|
2004-09-07 18:37:39 +04:00
|
|
|
double elapsed_time_start = cmSystemTools::GetTime();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->StartLogFile("Build", ofs)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
|
|
|
}
|
2005-01-27 18:15:01 +03:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Create lists of regular expression strings for errors, error exceptions,
|
|
|
|
// warnings and warning exceptions.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string>::size_type cc;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Pre-compile regular expressions objects for all regular expressions
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
2005-06-01 23:59:22 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
|
|
|
|
regexes.clear(); \
|
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, \
|
|
|
|
this << "Add " #regexes << std::endl, this->Quiet); \
|
2016-09-05 23:09:49 +03:00
|
|
|
for (it = (strings).begin(); it != (strings).end(); ++it) { \
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, \
|
|
|
|
"Add " #strings ": " << *it << std::endl, \
|
|
|
|
this->Quiet); \
|
2016-09-05 23:09:49 +03:00
|
|
|
(regexes).push_back(it->c_str()); \
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
|
|
|
|
this->ErrorMatchRegex);
|
|
|
|
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
|
|
|
|
this->ErrorExceptionRegex);
|
|
|
|
cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
|
|
|
|
this->WarningMatchRegex);
|
|
|
|
cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
|
|
|
|
this->WarningExceptionRegex);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Determine source and binary tree substitutions to simplify the output.
|
2006-03-10 23:03:09 +03:00
|
|
|
this->SimplifySourceDir = "";
|
|
|
|
this->SimplifyBuildDir = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
|
|
|
|
std::string srcdir =
|
|
|
|
this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
|
2004-09-07 18:37:39 +04:00
|
|
|
std::string srcdirrep;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = srcdir.size() - 2; cc > 0; cc--) {
|
|
|
|
if (srcdir[cc] == '/') {
|
2004-09-07 18:37:39 +04:00
|
|
|
srcdirrep = srcdir.c_str() + cc;
|
|
|
|
srcdirrep = "/..." + srcdirrep;
|
2016-05-16 17:34:04 +03:00
|
|
|
srcdir = srcdir.substr(0, cc + 1);
|
2004-09-07 18:37:39 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SimplifySourceDir = srcdir;
|
|
|
|
}
|
|
|
|
if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
|
|
|
|
std::string bindir =
|
|
|
|
this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
|
2005-06-01 23:59:22 +04:00
|
|
|
std::string bindirrep;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = bindir.size() - 2; cc > 0; cc--) {
|
|
|
|
if (bindir[cc] == '/') {
|
2004-09-07 18:37:39 +04:00
|
|
|
bindirrep = bindir.c_str() + cc;
|
|
|
|
bindirrep = "/..." + bindirrep;
|
2016-05-16 17:34:04 +03:00
|
|
|
bindir = bindir.substr(0, cc + 1);
|
2004-09-07 18:37:39 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SimplifyBuildDir = bindir;
|
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Ok, let's do the build
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Remember start build time
|
2006-03-10 23:03:09 +03:00
|
|
|
this->StartBuild = this->CTest->CurrentTime();
|
2008-01-30 19:17:36 +03:00
|
|
|
this->StartBuildTime = cmSystemTools::GetTime();
|
2005-06-01 23:59:22 +04:00
|
|
|
int retVal = 0;
|
|
|
|
int res = cmsysProcess_State_Exited;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTest->GetShowOnly()) {
|
2006-03-09 19:17:10 +03:00
|
|
|
res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
|
2016-05-16 17:34:04 +03:00
|
|
|
buildDirectory.c_str(), 0, ofs);
|
|
|
|
} else {
|
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"Build with command: " << makeCommand << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Remember end build time and calculate elapsed time
|
2006-03-10 23:03:09 +03:00
|
|
|
this->EndBuild = this->CTest->CurrentTime();
|
2008-01-30 19:17:36 +03:00
|
|
|
this->EndBuildTime = cmSystemTools::GetTime();
|
2005-06-01 23:59:22 +04:00
|
|
|
double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start;
|
|
|
|
|
|
|
|
// Cleanups strings in the errors and warnings list.
|
|
|
|
t_ErrorsAndWarningsVector::iterator evit;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SimplifySourceDir.empty()) {
|
|
|
|
for (evit = this->ErrorsAndWarnings.begin();
|
|
|
|
evit != this->ErrorsAndWarnings.end(); ++evit) {
|
|
|
|
cmSystemTools::ReplaceString(evit->Text, this->SimplifySourceDir.c_str(),
|
|
|
|
"/.../");
|
|
|
|
cmSystemTools::ReplaceString(evit->PreContext,
|
|
|
|
this->SimplifySourceDir.c_str(), "/.../");
|
|
|
|
cmSystemTools::ReplaceString(evit->PostContext,
|
|
|
|
this->SimplifySourceDir.c_str(), "/.../");
|
2004-09-07 18:37:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!this->SimplifyBuildDir.empty()) {
|
|
|
|
for (evit = this->ErrorsAndWarnings.begin();
|
|
|
|
evit != this->ErrorsAndWarnings.end(); ++evit) {
|
|
|
|
cmSystemTools::ReplaceString(evit->Text, this->SimplifyBuildDir.c_str(),
|
|
|
|
"/.../");
|
|
|
|
cmSystemTools::ReplaceString(evit->PreContext,
|
|
|
|
this->SimplifyBuildDir.c_str(), "/.../");
|
|
|
|
cmSystemTools::ReplaceString(evit->PostContext,
|
|
|
|
this->SimplifyBuildDir.c_str(), "/.../");
|
2004-09-07 18:37:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-07 18:37:39 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Generate XML output
|
2005-01-27 18:15:01 +03:00
|
|
|
cmGeneratedFileStream xofs;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 22:36:12 +03:00
|
|
|
cmXMLWriter xml(xofs);
|
|
|
|
this->GenerateXMLHeader(xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseCTestLaunch) {
|
2015-05-24 22:36:12 +03:00
|
|
|
this->GenerateXMLLaunched(xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-05-24 22:36:12 +03:00
|
|
|
this->GenerateXMLLogScraped(xml);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 22:36:12 +03:00
|
|
|
this->GenerateXMLFooter(xml, elapsed_build_time);
|
2009-02-04 22:34:25 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
|
2009-09-21 21:40:40 +04:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
|
|
|
}
|
2009-09-21 21:40:40 +04:00
|
|
|
|
2009-02-04 22:34:25 +03:00
|
|
|
// Display message about number of errors and warnings
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
|
|
|
|
<< this->TotalErrors
|
|
|
|
<< (this->TotalErrors >= this->MaxErrors ? " or more" : "")
|
|
|
|
<< " Compiler errors" << std::endl);
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
|
|
|
|
<< this->TotalWarnings
|
|
|
|
<< (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
|
|
|
|
<< " Compiler warnings" << std::endl);
|
2009-02-04 22:34:25 +03:00
|
|
|
|
2009-01-14 21:48:03 +03:00
|
|
|
return retVal;
|
2004-09-07 18:37:39 +04:00
|
|
|
}
|
|
|
|
|
2015-05-24 22:36:12 +03:00
|
|
|
void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
|
2004-09-07 18:37:39 +04:00
|
|
|
{
|
2015-05-24 22:36:12 +03:00
|
|
|
this->CTest->StartXML(xml, this->AppendXML);
|
|
|
|
xml.StartElement("Build");
|
|
|
|
xml.Element("StartDateTime", this->StartBuild);
|
|
|
|
xml.Element("StartBuildTime",
|
2016-05-16 17:34:04 +03:00
|
|
|
static_cast<unsigned int>(this->StartBuildTime));
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Element("BuildCommand", this->GetMakeCommand());
|
2009-02-04 22:34:12 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
class cmCTestBuildHandler::FragmentCompare
|
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
FragmentCompare(cmFileTimeComparison* ftc)
|
|
|
|
: FTC(ftc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
FragmentCompare()
|
2016-06-27 23:44:16 +03:00
|
|
|
: FTC(CM_NULLPTR)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
bool operator()(std::string const& l, std::string const& r)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2009-02-12 18:01:39 +03:00
|
|
|
// Order files by modification time. Use lexicographic order
|
|
|
|
// among files with the same time.
|
2009-02-11 23:18:08 +03:00
|
|
|
int result;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
|
|
|
|
result != 0) {
|
2009-02-11 23:18:08 +03:00
|
|
|
return result < 0;
|
|
|
|
}
|
2016-08-18 21:04:21 +03:00
|
|
|
return l < r;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
private:
|
|
|
|
cmFileTimeComparison* FTC;
|
|
|
|
};
|
|
|
|
|
2015-05-24 22:36:12 +03:00
|
|
|
void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
|
2009-02-11 23:18:08 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CTestLaunchDir.empty()) {
|
2009-02-11 23:18:08 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
|
|
|
|
// Sort XML fragments in chronological order.
|
|
|
|
cmFileTimeComparison ftc;
|
|
|
|
FragmentCompare fragmentCompare(&ftc);
|
2014-02-10 09:21:34 +04:00
|
|
|
typedef std::set<std::string, FragmentCompare> Fragments;
|
2009-02-11 23:18:08 +03:00
|
|
|
Fragments fragments(fragmentCompare);
|
|
|
|
|
2014-06-24 21:35:35 +04:00
|
|
|
// only report the first 50 warnings and first 50 errors
|
|
|
|
int numErrorsAllowed = this->MaxErrors;
|
|
|
|
int numWarningsAllowed = this->MaxWarnings;
|
2009-02-11 23:18:08 +03:00
|
|
|
// Identify fragments on disk.
|
|
|
|
cmsys::Directory launchDir;
|
2014-10-15 16:54:05 +04:00
|
|
|
launchDir.Load(this->CTestLaunchDir);
|
2009-02-11 23:18:08 +03:00
|
|
|
unsigned long n = launchDir.GetNumberOfFiles();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < n; ++i) {
|
2009-02-11 23:18:08 +03:00
|
|
|
const char* fname = launchDir.GetFile(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
|
2014-06-24 21:35:35 +04:00
|
|
|
numErrorsAllowed--;
|
2009-02-11 23:18:08 +03:00
|
|
|
fragments.insert(this->CTestLaunchDir + "/" + fname);
|
|
|
|
++this->TotalErrors;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
|
2014-06-24 21:35:35 +04:00
|
|
|
numWarningsAllowed--;
|
2009-02-11 23:18:08 +03:00
|
|
|
fragments.insert(this->CTestLaunchDir + "/" + fname);
|
|
|
|
++this->TotalWarnings;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
|
|
|
|
// Copy the fragments into the final XML file.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (Fragments::const_iterator fi = fragments.begin(); fi != fragments.end();
|
|
|
|
++fi) {
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.FragmentFile(fi->c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
2015-05-24 22:36:12 +03:00
|
|
|
void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
|
2009-02-04 22:34:12 +03:00
|
|
|
{
|
|
|
|
std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
|
2004-09-07 18:37:39 +04:00
|
|
|
std::vector<cmCTestBuildErrorWarning>::iterator it;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-01-12 21:51:20 +03:00
|
|
|
// only report the first 50 warnings and first 50 errors
|
2009-10-02 00:47:08 +04:00
|
|
|
int numErrorsAllowed = this->MaxErrors;
|
|
|
|
int numWarningsAllowed = this->MaxWarnings;
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
|
2005-04-07 21:03:47 +04:00
|
|
|
// make sure the source dir is in the correct case on windows
|
|
|
|
// via a call to collapse full path.
|
2014-10-15 16:54:05 +04:00
|
|
|
srcdir = cmSystemTools::CollapseFullPath(srcdir);
|
2005-04-07 21:03:47 +04:00
|
|
|
srcdir += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = ew.begin();
|
|
|
|
it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
|
|
|
|
cmCTestBuildErrorWarning* cm = &(*it);
|
2009-09-11 16:18:15 +04:00
|
|
|
if ((cm->Error && numErrorsAllowed) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
(!cm->Error && numWarningsAllowed)) {
|
|
|
|
if (cm->Error) {
|
2005-01-12 21:51:20 +03:00
|
|
|
numErrorsAllowed--;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-01-12 21:51:20 +03:00
|
|
|
numWarningsAllowed--;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.StartElement(cm->Error ? "Error" : "Warning");
|
|
|
|
xml.Element("BuildLogLine", cm->LogLine);
|
|
|
|
xml.Element("Text", cm->Text);
|
2005-01-12 21:51:20 +03:00
|
|
|
std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (rit = this->ErrorWarningFileLineRegex.begin();
|
|
|
|
rit != this->ErrorWarningFileLineRegex.end(); ++rit) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmsys::RegularExpression* re = &rit->RegularExpression;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (re->find(cm->Text.c_str())) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cm->SourceFile = re->match(rit->FileIndex);
|
|
|
|
// At this point we need to make this->SourceFile relative to
|
2005-04-07 21:03:47 +04:00
|
|
|
// the source root of the project, so cvs links will work
|
2006-03-10 23:03:09 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cm->SourceFile.find("/.../") != cm->SourceFile.npos) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
|
2016-05-24 22:24:10 +03:00
|
|
|
std::string::size_type p = cm->SourceFile.find('/');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (p != cm->SourceFile.npos) {
|
|
|
|
cm->SourceFile =
|
|
|
|
cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
|
2005-04-07 21:03:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-04-07 21:03:47 +04:00
|
|
|
// make sure it is a full path with the correct case
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
|
|
|
|
cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cm->LineNumber = atoi(re->match(rit->LineIndex).c_str());
|
2005-01-12 21:51:20 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
|
|
|
|
if (!cm->SourceFile.empty()) {
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Element("SourceFile", cm->SourceFile);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cm->SourceFileTail.empty()) {
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Element("SourceFileTail", cm->SourceFileTail);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cm->LineNumber >= 0) {
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Element("SourceLineNumber", cm->LineNumber);
|
2005-01-12 21:51:20 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Element("PreContext", cm->PreContext);
|
|
|
|
xml.StartElement("PostContext");
|
|
|
|
xml.Content(cm->PostContext);
|
2005-01-12 21:51:20 +03:00
|
|
|
// is this the last warning or error, if so notify
|
2009-09-11 16:18:15 +04:00
|
|
|
if ((cm->Error && !numErrorsAllowed) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
(!cm->Error && !numWarningsAllowed)) {
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.Content("\nThe maximum number of reported warnings or errors "
|
2016-05-16 17:34:04 +03:00
|
|
|
"has been reached!!!\n");
|
|
|
|
}
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.EndElement(); // PostContext
|
|
|
|
xml.Element("RepeatCount", "0");
|
|
|
|
xml.EndElement(); // "Error" / "Warning"
|
2004-09-07 18:37:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-04 22:34:12 +03:00
|
|
|
}
|
|
|
|
|
2015-05-24 22:36:12 +03:00
|
|
|
void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
|
2009-02-04 22:34:12 +03:00
|
|
|
double elapsed_build_time)
|
|
|
|
{
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.StartElement("Log");
|
|
|
|
xml.Attribute("Encoding", "base64");
|
|
|
|
xml.Attribute("Compression", "bin/gzip");
|
|
|
|
xml.EndElement(); // Log
|
|
|
|
|
|
|
|
xml.Element("EndDateTime", this->EndBuild);
|
|
|
|
xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
|
2016-05-16 17:34:04 +03:00
|
|
|
xml.Element("ElapsedMinutes",
|
|
|
|
static_cast<int>(elapsed_build_time / 6) / 10.0);
|
2015-05-24 22:36:12 +03:00
|
|
|
xml.EndElement(); // Build
|
|
|
|
this->CTest->EndXML(xml);
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
|
|
|
|
{
|
|
|
|
// error-{hash}.xml
|
2013-11-20 05:12:00 +04:00
|
|
|
return (cmHasLiteralPrefix(fname, "error-") &&
|
2016-05-16 17:34:04 +03:00
|
|
|
strcmp(fname + strlen(fname) - 4, ".xml") == 0);
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
|
|
|
|
{
|
|
|
|
// warning-{hash}.xml
|
2013-11-20 05:12:00 +04:00
|
|
|
return (cmHasLiteralPrefix(fname, "warning-") &&
|
2016-05-16 17:34:04 +03:00
|
|
|
strcmp(fname + strlen(fname) - 4, ".xml") == 0);
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
2005-06-10 16:56:56 +04:00
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
class cmCTestBuildHandler::LaunchHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LaunchHelper(cmCTestBuildHandler* handler);
|
|
|
|
~LaunchHelper();
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
private:
|
|
|
|
cmCTestBuildHandler* Handler;
|
|
|
|
cmCTest* CTest;
|
|
|
|
|
2009-02-12 21:00:22 +03:00
|
|
|
void WriteLauncherConfig();
|
2009-02-11 23:18:08 +03:00
|
|
|
void WriteScrapeMatchers(const char* purpose,
|
|
|
|
std::vector<std::string> const& matchers);
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
|
|
|
|
: Handler(handler)
|
|
|
|
, CTest(handler->CTest)
|
2009-02-11 23:18:08 +03:00
|
|
|
{
|
|
|
|
std::string tag = this->CTest->GetCurrentTag();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tag.empty()) {
|
2009-02-11 23:18:08 +03:00
|
|
|
// This is not for a dashboard submission, so there is no XML.
|
|
|
|
// Skip enabling the launchers.
|
|
|
|
this->Handler->UseCTestLaunch = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-02-11 23:18:08 +03:00
|
|
|
// Compute a directory in which to store launcher fragments.
|
|
|
|
std::string& launchDir = this->Handler->CTestLaunchDir;
|
|
|
|
launchDir = this->CTest->GetBinaryDir();
|
|
|
|
launchDir += "/Testing/";
|
|
|
|
launchDir += tag;
|
|
|
|
launchDir += "/Build";
|
|
|
|
|
|
|
|
// Clean out any existing launcher fragments.
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(launchDir);
|
2009-02-11 23:18:08 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Handler->UseCTestLaunch) {
|
2009-02-11 23:18:08 +03:00
|
|
|
// Enable launcher fragments.
|
|
|
|
cmSystemTools::MakeDirectory(launchDir.c_str());
|
2009-02-12 21:00:22 +03:00
|
|
|
this->WriteLauncherConfig();
|
2009-02-11 23:18:08 +03:00
|
|
|
std::string launchEnv = "CTEST_LAUNCH_LOGS=";
|
|
|
|
launchEnv += launchDir;
|
2014-11-23 13:05:50 +03:00
|
|
|
cmSystemTools::PutEnv(launchEnv);
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
|
|
|
|
// If not using launchers, make sure they passthru.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Handler->UseCTestLaunch) {
|
2009-02-11 23:18:08 +03:00
|
|
|
cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Handler->UseCTestLaunch) {
|
2009-02-11 23:18:08 +03:00
|
|
|
cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
2009-02-12 21:00:22 +03:00
|
|
|
void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
|
2009-02-11 23:18:08 +03:00
|
|
|
{
|
|
|
|
this->WriteScrapeMatchers("Warning",
|
|
|
|
this->Handler->ReallyCustomWarningMatches);
|
|
|
|
this->WriteScrapeMatchers("WarningSuppress",
|
|
|
|
this->Handler->ReallyCustomWarningExceptions);
|
2009-02-12 21:00:22 +03:00
|
|
|
|
|
|
|
// Give some testing configuration information to the launcher.
|
|
|
|
std::string fname = this->Handler->CTestLaunchDir;
|
|
|
|
fname += "/CTestLaunchConfig.cmake";
|
|
|
|
cmGeneratedFileStream fout(fname.c_str());
|
|
|
|
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
|
|
|
|
fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
|
|
|
|
const char* purpose, std::vector<std::string> const& matchers)
|
2009-02-11 23:18:08 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (matchers.empty()) {
|
2009-02-11 23:18:08 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
std::string fname = this->Handler->CTestLaunchDir;
|
|
|
|
fname += "/Custom";
|
|
|
|
fname += purpose;
|
|
|
|
fname += ".txt";
|
|
|
|
cmGeneratedFileStream fout(fname.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator mi = matchers.begin();
|
|
|
|
mi != matchers.end(); ++mi) {
|
2009-02-11 23:18:08 +03:00
|
|
|
fout << *mi << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
|
|
|
|
const char* dir, int timeout,
|
|
|
|
std::ostream& ofs)
|
2005-06-01 23:59:22 +04:00
|
|
|
{
|
|
|
|
// First generate the command and arguments
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
2016-05-27 00:05:30 +03:00
|
|
|
if (args.empty()) {
|
2005-06-01 23:59:22 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
std::vector<const char*> argv;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator a = args.begin();
|
|
|
|
a != args.end(); ++a) {
|
2005-06-01 23:59:22 +04:00
|
|
|
argv.push_back(a->c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
argv.push_back(CM_NULLPTR);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
2015-02-17 21:41:40 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2005-06-10 16:56:56 +04:00
|
|
|
std::vector<const char*>::iterator ait;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
" \"" << *ait << "\"", this->Quiet);
|
|
|
|
}
|
2015-02-17 21:41:40 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2009-02-11 23:18:08 +03:00
|
|
|
// Optionally use make rule launchers to record errors and warnings.
|
|
|
|
LaunchHelper launchHelper(this);
|
|
|
|
static_cast<void>(launchHelper);
|
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// Now create process object
|
|
|
|
cmsysProcess* cp = cmsysProcess_New();
|
|
|
|
cmsysProcess_SetCommand(cp, &*argv.begin());
|
|
|
|
cmsysProcess_SetWorkingDirectory(cp, dir);
|
|
|
|
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
|
|
|
cmsysProcess_SetTimeout(cp, timeout);
|
|
|
|
cmsysProcess_Execute(cp);
|
|
|
|
|
|
|
|
// Initialize tick's
|
|
|
|
std::string::size_type tick = 0;
|
|
|
|
const std::string::size_type tick_len = 1024;
|
|
|
|
|
|
|
|
char* data;
|
|
|
|
int length;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents "
|
|
|
|
<< tick_len << " bytes of output." << std::endl
|
|
|
|
<< (this->UseCTestLaunch
|
|
|
|
? ""
|
|
|
|
: " '!' represents an error and '*' a warning.\n")
|
|
|
|
<< " " << std::flush,
|
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Initialize building structures
|
2006-03-10 23:03:09 +03:00
|
|
|
this->BuildProcessingQueue.clear();
|
|
|
|
this->OutputLineCounter = 0;
|
|
|
|
this->ErrorsAndWarnings.clear();
|
|
|
|
this->TotalErrors = 0;
|
|
|
|
this->TotalWarnings = 0;
|
|
|
|
this->BuildOutputLogSize = 0;
|
|
|
|
this->LastTickChar = '.';
|
|
|
|
this->WarningQuotaReached = false;
|
|
|
|
this->ErrorQuotaReached = false;
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// For every chunk of data
|
2006-01-27 21:46:33 +03:00
|
|
|
int res;
|
2016-06-27 23:44:16 +03:00
|
|
|
while ((res = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR))) {
|
2005-06-01 23:59:22 +04:00
|
|
|
// Replace '\0' with '\n', since '\0' does not really make sense. This is
|
|
|
|
// for Visual Studio output
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int cc = 0; cc < length; ++cc) {
|
|
|
|
if (data[cc] == 0) {
|
2005-06-01 23:59:22 +04:00
|
|
|
data[cc] = '\n';
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Process the chunk of data
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res == cmsysProcess_Pipe_STDERR) {
|
2006-03-09 19:17:10 +03:00
|
|
|
this->ProcessBuffer(data, length, tick, tick_len, ofs,
|
2016-05-16 17:34:04 +03:00
|
|
|
&this->BuildProcessingErrorQueue);
|
|
|
|
} else {
|
2006-03-09 19:17:10 +03:00
|
|
|
this->ProcessBuffer(data, length, tick, tick_len, ofs,
|
2016-05-16 17:34:04 +03:00
|
|
|
&this->BuildProcessingQueue);
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs,
|
|
|
|
&this->BuildProcessingQueue);
|
|
|
|
this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs,
|
2016-05-16 17:34:04 +03:00
|
|
|
&this->BuildProcessingErrorQueue);
|
2015-07-03 23:52:23 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< ((this->BuildOutputLogSize + 512) / 1024) << "K"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Properly handle output of the build command
|
2016-06-27 23:44:16 +03:00
|
|
|
cmsysProcess_WaitForExit(cp, CM_NULLPTR);
|
2005-06-01 23:59:22 +04:00
|
|
|
int result = cmsysProcess_GetState(cp);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result == cmsysProcess_State_Exited) {
|
|
|
|
if (retVal) {
|
2007-03-28 19:06:34 +04:00
|
|
|
*retVal = cmsysProcess_GetExitValue(cp);
|
2015-02-17 21:41:40 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Command exited with the value: " << *retVal
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2007-03-28 19:06:34 +04:00
|
|
|
// if a non zero return value
|
2016-05-16 17:34:04 +03:00
|
|
|
if (*retVal) {
|
2007-04-04 21:06:20 +04:00
|
|
|
// If there was an error running command, report that on the
|
|
|
|
// dashboard.
|
2007-03-28 19:06:34 +04:00
|
|
|
cmCTestBuildErrorWarning errorwarning;
|
2016-05-16 17:34:04 +03:00
|
|
|
errorwarning.LogLine = 1;
|
|
|
|
errorwarning.Text =
|
|
|
|
"*** WARNING non-zero return value in ctest from: ";
|
|
|
|
errorwarning.Text += argv[0];
|
|
|
|
errorwarning.PreContext = "";
|
2007-03-28 19:06:34 +04:00
|
|
|
errorwarning.PostContext = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
errorwarning.Error = false;
|
2007-03-28 19:06:34 +04:00
|
|
|
this->ErrorsAndWarnings.push_back(errorwarning);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->TotalWarnings++;
|
2007-03-20 21:31:34 +03:00
|
|
|
}
|
2007-03-28 19:07:36 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Exception) {
|
|
|
|
if (retVal) {
|
2007-03-28 19:07:36 +04:00
|
|
|
*retVal = cmsysProcess_GetExitException(cp);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, WARNING,
|
|
|
|
"There was an exception: " << *retVal << std::endl,
|
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Expired) {
|
|
|
|
cmCTestOptionalLog(this->CTest, WARNING,
|
|
|
|
"There was a timeout" << std::endl, this->Quiet);
|
|
|
|
} else if (result == cmsysProcess_State_Error) {
|
2005-06-01 23:59:22 +04:00
|
|
|
// If there was an error running command, report that on the dashboard.
|
|
|
|
cmCTestBuildErrorWarning errorwarning;
|
2016-05-16 17:34:04 +03:00
|
|
|
errorwarning.LogLine = 1;
|
|
|
|
errorwarning.Text = "*** ERROR executing: ";
|
|
|
|
errorwarning.Text += cmsysProcess_GetErrorString(cp);
|
|
|
|
errorwarning.PreContext = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
errorwarning.PostContext = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
errorwarning.Error = true;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ErrorsAndWarnings.push_back(errorwarning);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->TotalErrors++;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl);
|
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
cmsysProcess_Delete(cp);
|
2009-01-14 21:48:03 +03:00
|
|
|
return result;
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
|
|
|
|
2005-06-10 16:56:56 +04:00
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
//######################################################################
|
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
|
2016-05-16 17:34:04 +03:00
|
|
|
size_t& tick, size_t tick_len,
|
|
|
|
std::ostream& ofs,
|
|
|
|
t_BuildProcessingQueueType* queue)
|
2005-06-01 23:59:22 +04:00
|
|
|
{
|
|
|
|
const std::string::size_type tick_line_len = 50;
|
2005-06-02 19:47:10 +04:00
|
|
|
const char* ptr;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ptr = data; ptr < data + length; ptr++) {
|
2006-01-27 21:46:33 +03:00
|
|
|
queue->push_back(*ptr);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
this->BuildOutputLogSize += length;
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// until there are any lines left in the buffer
|
2016-05-16 17:34:04 +03:00
|
|
|
while (1) {
|
2005-06-01 23:59:22 +04:00
|
|
|
// Find the end of line
|
|
|
|
t_BuildProcessingQueueType::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = queue->begin(); it != queue->end(); ++it) {
|
|
|
|
if (*it == '\n') {
|
2005-06-01 23:59:22 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-02 19:47:10 +04:00
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
// Once certain number of errors or warnings reached, ignore future errors
|
|
|
|
// or warnings.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->TotalWarnings >= this->MaxWarnings) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->WarningQuotaReached = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->TotalErrors >= this->MaxErrors) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ErrorQuotaReached = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-02 19:47:10 +04:00
|
|
|
|
2005-06-01 23:59:22 +04:00
|
|
|
// If the end of line was found
|
2016-05-16 17:34:04 +03:00
|
|
|
if (it != queue->end()) {
|
2005-06-01 23:59:22 +04:00
|
|
|
// Create a contiguous array for the line
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CurrentProcessingLine.clear();
|
2014-11-22 13:00:45 +03:00
|
|
|
this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
|
2015-01-15 17:28:21 +03:00
|
|
|
queue->begin(), it);
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CurrentProcessingLine.push_back(0);
|
|
|
|
const char* line = &*this->CurrentProcessingLine.begin();
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Process the line
|
|
|
|
int lineType = this->ProcessSingleLine(line);
|
|
|
|
|
|
|
|
// Erase the line from the queue
|
2016-05-16 17:34:04 +03:00
|
|
|
queue->erase(queue->begin(), it + 1);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Depending on the line type, produce error or warning, or nothing
|
|
|
|
cmCTestBuildErrorWarning errorwarning;
|
|
|
|
bool found = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (lineType) {
|
|
|
|
case b_WARNING_LINE:
|
|
|
|
this->LastTickChar = '*';
|
|
|
|
errorwarning.Error = false;
|
|
|
|
found = true;
|
|
|
|
this->TotalWarnings++;
|
|
|
|
break;
|
|
|
|
case b_ERROR_LINE:
|
|
|
|
this->LastTickChar = '!';
|
|
|
|
errorwarning.Error = true;
|
|
|
|
found = true;
|
|
|
|
this->TotalErrors++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (found) {
|
2005-06-01 23:59:22 +04:00
|
|
|
// This is an error or warning, so generate report
|
2016-05-16 17:34:04 +03:00
|
|
|
errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
|
|
|
|
errorwarning.Text = line;
|
|
|
|
errorwarning.PreContext = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
errorwarning.PostContext = "";
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Copy pre-context to report
|
2014-02-10 09:21:34 +04:00
|
|
|
std::deque<std::string>::iterator pcit;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (pcit = this->PreContext.begin(); pcit != this->PreContext.end();
|
|
|
|
++pcit) {
|
2006-03-10 23:03:09 +03:00
|
|
|
errorwarning.PreContext += *pcit + "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
this->PreContext.clear();
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Store report
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ErrorsAndWarnings.push_back(errorwarning);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->PostContextCount = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-06-01 23:59:22 +04:00
|
|
|
// This is not an error or warning.
|
|
|
|
// So, figure out if this is a post-context line
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ErrorsAndWarnings.empty() &&
|
|
|
|
this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
|
|
|
|
this->PostContextCount < this->MaxPostContext) {
|
|
|
|
this->PostContextCount++;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->LastErrorOrWarning->PostContext += line;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PostContextCount < this->MaxPostContext) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->LastErrorOrWarning->PostContext += "\n";
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-06-01 23:59:22 +04:00
|
|
|
// Otherwise store pre-context for the next error
|
2006-03-10 23:03:09 +03:00
|
|
|
this->PreContext.push_back(line);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PreContext.size() > this->MaxPreContext) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->PreContext.erase(this->PreContext.begin(),
|
2016-05-16 17:34:04 +03:00
|
|
|
this->PreContext.end() -
|
|
|
|
this->MaxPreContext);
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->OutputLineCounter++;
|
|
|
|
} else {
|
2005-06-01 23:59:22 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Now that the buffer is processed, display missing ticks
|
|
|
|
int tickDisplayed = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (this->BuildOutputLogSize > (tick * tick_len)) {
|
|
|
|
tick++;
|
2015-07-03 23:52:23 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LastTickChar, this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
tickDisplayed = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tick % tick_line_len == 0 && tick > 0) {
|
2015-07-03 23:52:23 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< ((this->BuildOutputLogSize + 512) / 1024) << "K"
|
|
|
|
<< std::endl
|
|
|
|
<< " ",
|
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (tickDisplayed) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->LastTickChar = '.';
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// And if this is verbose output, display the content of the chunk
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLogWrite(data, length));
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
// Always store the chunk to the file
|
|
|
|
ofs << cmCTestLogWrite(data, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestBuildHandler::ProcessSingleLine(const char* data)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseCTestLaunch) {
|
2009-02-11 23:18:08 +03:00
|
|
|
// No log scraping when using launchers.
|
|
|
|
return b_REGULAR_LINE;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-11 23:18:08 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
|
|
|
|
this->Quiet);
|
2005-06-01 23:59:22 +04:00
|
|
|
|
|
|
|
std::vector<cmsys::RegularExpression>::iterator it;
|
|
|
|
|
|
|
|
int warningLine = 0;
|
|
|
|
int errorLine = 0;
|
|
|
|
|
|
|
|
// Check for regular expressions
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ErrorQuotaReached) {
|
2006-03-09 19:17:10 +03:00
|
|
|
// Errors
|
2006-04-27 23:23:39 +04:00
|
|
|
int wrxCnt = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->ErrorMatchRegex.begin(); it != this->ErrorMatchRegex.end();
|
|
|
|
++it) {
|
|
|
|
if (it->find(data)) {
|
2005-06-02 19:47:10 +04:00
|
|
|
errorLine = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
" Error Line: " << data << " (matches: "
|
|
|
|
<< this->CustomErrorMatches[wrxCnt]
|
|
|
|
<< ")" << std::endl,
|
|
|
|
this->Quiet);
|
2005-06-02 19:47:10 +04:00
|
|
|
break;
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
wrxCnt++;
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
// Error exceptions
|
2006-04-27 23:23:39 +04:00
|
|
|
wrxCnt = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->ErrorExceptionRegex.begin();
|
|
|
|
it != this->ErrorExceptionRegex.end(); ++it) {
|
|
|
|
if (it->find(data)) {
|
2005-06-02 19:47:10 +04:00
|
|
|
errorLine = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: "
|
|
|
|
<< data << " (matches: "
|
|
|
|
<< this->CustomErrorExceptions[wrxCnt] << ")"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2005-06-02 19:47:10 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
wrxCnt++;
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->WarningQuotaReached) {
|
2005-06-02 19:47:10 +04:00
|
|
|
// Warnings
|
2006-04-27 23:23:39 +04:00
|
|
|
int wrxCnt = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->WarningMatchRegex.begin();
|
|
|
|
it != this->WarningMatchRegex.end(); ++it) {
|
|
|
|
if (it->find(data)) {
|
2005-06-02 19:47:10 +04:00
|
|
|
warningLine = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, " Warning Line: "
|
|
|
|
<< data << " (matches: "
|
|
|
|
<< this->CustomWarningMatches[wrxCnt] << ")"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2005-06-02 19:47:10 +04:00
|
|
|
break;
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
wrxCnt++;
|
|
|
|
}
|
2005-06-02 19:47:10 +04:00
|
|
|
|
2006-04-27 23:23:39 +04:00
|
|
|
wrxCnt = 0;
|
2005-06-02 19:47:10 +04:00
|
|
|
// Warning exceptions
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->WarningExceptionRegex.begin();
|
|
|
|
it != this->WarningExceptionRegex.end(); ++it) {
|
|
|
|
if (it->find(data)) {
|
2005-06-02 19:47:10 +04:00
|
|
|
warningLine = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: "
|
|
|
|
<< data << " (matches: "
|
|
|
|
<< this->CustomWarningExceptions[wrxCnt] << ")"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2005-06-02 19:47:10 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
wrxCnt++;
|
2005-06-01 23:59:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (errorLine) {
|
2005-06-01 23:59:22 +04:00
|
|
|
return b_ERROR_LINE;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (warningLine) {
|
2005-06-01 23:59:22 +04:00
|
|
|
return b_WARNING_LINE;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 23:59:22 +04:00
|
|
|
return b_REGULAR_LINE;
|
|
|
|
}
|