mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 06:00:29 +02:00
fpts2junit: fix compilation, remove non printable chars from xml text, cut big error texts to last 1000 chars
git-svn-id: trunk@36372 -
This commit is contained in:
parent
1252aefb86
commit
ee5096c2ec
@ -24,6 +24,7 @@ uses
|
||||
DOM, XMLWrite;
|
||||
|
||||
const
|
||||
MAX_XML_CHARS = 1000;
|
||||
LOG_SHORT = 'log';
|
||||
LOG_LONG = 'longlog';
|
||||
|
||||
@ -66,11 +67,13 @@ var
|
||||
skipped: LongInt;
|
||||
success: LongInt;
|
||||
tmpLine: String;
|
||||
Line: string;
|
||||
|
||||
startIdx: LongInt;
|
||||
tmpString: String;
|
||||
className: String;
|
||||
caseName: String;
|
||||
i: Integer;
|
||||
begin
|
||||
logShort:=TStringList.Create;
|
||||
logLong:=TStringList.Create;
|
||||
@ -102,8 +105,9 @@ begin
|
||||
rootNode:=junitXML.CreateElement('testsuite');
|
||||
junitXML.AppendChild(rootNode);
|
||||
|
||||
for tmpLine in logShort do
|
||||
for Line in logShort do
|
||||
begin
|
||||
tmpline := Line;
|
||||
// this is pretty fubar in the logfile, to break the format
|
||||
// lets fix it up...
|
||||
if AnsiEndsText(IE_FUBAR, tmpLine) then
|
||||
@ -118,8 +122,8 @@ begin
|
||||
|
||||
// create testcase node
|
||||
caseNode:=junitXML.CreateElement('testcase');
|
||||
TDOMElement(caseNode).SetAttribute('classname',className);
|
||||
TDOMElement(caseNode).SetAttribute('name',caseName);
|
||||
TDOMElement(caseNode).SetAttribute('classname',WideString(className));
|
||||
TDOMElement(caseNode).SetAttribute('name',WideString(caseName));
|
||||
rootNode.AppendChild(caseNode);
|
||||
|
||||
if AnsiStartsText(PATTERN_FAILED, tmpLine) then
|
||||
@ -138,7 +142,7 @@ begin
|
||||
tmpNode:=junitXML.CreateElement('failure');
|
||||
end;
|
||||
|
||||
TDOMElement(tmpNode).SetAttribute('message',tmpString);
|
||||
TDOMElement(tmpNode).SetAttribute('message',WideString(tmpString));
|
||||
startIdx:=getIndexInList(logLong, className, caseName);
|
||||
tmpString:='';
|
||||
while startIdx > 0 do
|
||||
@ -149,7 +153,14 @@ begin
|
||||
AnsiStartsText('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', logLong[startIdx]) then break;
|
||||
end;
|
||||
if tmpString <> '' then
|
||||
tmpNode.AppendChild(junitXML.CreateTextNode(tmpString+#10));
|
||||
begin
|
||||
if Length(tmpString) > MAX_XML_CHARS then
|
||||
tmpString := '--- ' + IntToStr(Length(tmpstring) - MAX_XML_CHARS) + 'bytes cut away --- '+ #10 + Copy(tmpString, Length(tmpstring) - MAX_XML_CHARS, MAX_XML_CHARS);
|
||||
for i := 1 to Length(tmpString) do
|
||||
if tmpString[i] in [#0..#9,#11..#31] then
|
||||
tmpString[i] := ' ';
|
||||
tmpNode.AppendChild(junitXML.CreateTextNode(WideString(tmpString+#10)));
|
||||
end;
|
||||
caseNode.AppendChild(tmpNode);
|
||||
continue;
|
||||
end;
|
||||
@ -169,9 +180,9 @@ begin
|
||||
end;
|
||||
|
||||
// set required elements in the root node
|
||||
TDOMElement(rootNode).SetAttribute('errors',IntToStr(error));
|
||||
TDOMElement(rootNode).SetAttribute('failures',IntToStr(failed));
|
||||
TDOMElement(rootNode).SetAttribute('tests',IntToStr(logShort.Count));
|
||||
TDOMElement(rootNode).SetAttribute('errors',WideString(IntToStr(error)));
|
||||
TDOMElement(rootNode).SetAttribute('failures',WideString(IntToStr(failed)));
|
||||
TDOMElement(rootNode).SetAttribute('tests',WideString(IntToStr(logShort.Count)));
|
||||
TDOMElement(rootNode).SetAttribute('name','Compiler.Testsuite');
|
||||
TDOMElement(rootNode).SetAttribute('package','FPC');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user