-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
427 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- based on https://gist.github.com/cdroulers/e23eeb31d6c1c2cade6f680e321aed8d --> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" cdata-section-elements="message stack-trace"/> | ||
<xsl:template match="/"> | ||
<testsuites> | ||
<xsl:for-each select="//assembly"> | ||
<testsuite> | ||
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> | ||
<xsl:attribute name="tests"><xsl:value-of select="@total"/></xsl:attribute> | ||
<xsl:attribute name="failures"><xsl:value-of select="@failed"/></xsl:attribute> | ||
<xsl:if test="@errors"> | ||
<xsl:attribute name="errors"><xsl:value-of select="@errors"/></xsl:attribute> | ||
</xsl:if> | ||
<xsl:attribute name="time"><xsl:value-of select="@time"/></xsl:attribute> | ||
<xsl:attribute name="skipped"><xsl:value-of select="@skipped"/></xsl:attribute> | ||
<xsl:attribute name="timestamp"><xsl:value-of select="@run-date"/>T<xsl:value-of select="@run-time"/></xsl:attribute> | ||
|
||
<xsl:for-each select="collection"> | ||
<xsl:sort select="@type" /> | ||
<testsuite> | ||
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> | ||
<xsl:attribute name="tests"><xsl:value-of select="@total"/></xsl:attribute> | ||
<xsl:attribute name="failures"><xsl:value-of select="@failed"/></xsl:attribute> | ||
<xsl:if test="@errors"> | ||
<xsl:attribute name="errors"><xsl:value-of select="@errors"/></xsl:attribute> | ||
</xsl:if> | ||
<xsl:attribute name="time"><xsl:value-of select="@time"/></xsl:attribute> | ||
<xsl:attribute name="skipped"><xsl:value-of select="@skipped"/></xsl:attribute> | ||
|
||
<xsl:for-each select="test"> | ||
<xsl:sort select="@name"/> | ||
<testcase> | ||
<xsl:attribute name="name"><xsl:value-of select="@method"/></xsl:attribute> | ||
<xsl:attribute name="time"><xsl:value-of select="@time"/></xsl:attribute> | ||
<xsl:attribute name="classname"><xsl:value-of select="@type"/></xsl:attribute> | ||
<xsl:if test="reason"> | ||
<skipped> | ||
<xsl:attribute name="message"><xsl:value-of select="reason/text()"/></xsl:attribute> | ||
</skipped> | ||
</xsl:if> | ||
<xsl:apply-templates select="failure"/> | ||
</testcase> | ||
</xsl:for-each> | ||
|
||
</testsuite> | ||
</xsl:for-each> | ||
|
||
</testsuite> | ||
</xsl:for-each> | ||
</testsuites> | ||
</xsl:template> | ||
|
||
<xsl:template match="failure"> | ||
<failure> | ||
<xsl:if test="@exception-type"> | ||
<xsl:attribute name="type"><xsl:value-of select="@exception-type"/></xsl:attribute> | ||
</xsl:if> | ||
<xsl:attribute name="message"><xsl:value-of select="message"/></xsl:attribute> | ||
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> | ||
<xsl:value-of select="stack-trace"/> | ||
<xsl:text disable-output-escaping="yes">]]></xsl:text> | ||
</failure> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import pathlib | ||
from typing import Iterable, Tuple, Union | ||
|
||
from junitparser import JUnitXml | ||
from lxml import etree | ||
|
||
|
||
with (pathlib.Path(__file__).parent / 'xslt' / 'xunit-to-junit.xslt').open('r', encoding='utf-8') as r: | ||
transform_xunit_to_junit = etree.XSLT(etree.parse(r)) | ||
|
||
|
||
def parse_xunit_files(files: Iterable[str]) -> Iterable[Tuple[str, Union[JUnitXml, BaseException]]]: | ||
"""Parses xunit files.""" | ||
def parse(path: str) -> Union[JUnitXml, BaseException]: | ||
if not os.path.exists(path): | ||
return FileNotFoundError(f'File does not exist.') | ||
if os.stat(path).st_size == 0: | ||
return Exception(f'File is empty.') | ||
|
||
try: | ||
trx = etree.parse(path) | ||
junit = transform_xunit_to_junit(trx) | ||
return JUnitXml.fromelem(junit.getroot()) | ||
except BaseException as e: | ||
return e | ||
|
||
return [(result_file, parse(result_file)) for result_file in files] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.