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
40 changed files
with
970 additions
and
31 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,63 @@ | ||
<?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"/> | ||
<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 | class"> | ||
<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"> | ||
<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:value-of select="message"/> | ||
<xsl:value-of select="stack-trace"/> | ||
</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,29 @@ | ||
import os | ||
import pathlib | ||
from typing import Iterable, Callable | ||
|
||
from lxml import etree | ||
|
||
from publish.junit import JUnitTreeOrException, ParsedJUnitFile | ||
|
||
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], | ||
progress: Callable[[ParsedJUnitFile], ParsedJUnitFile] = lambda x: x) -> Iterable[ParsedJUnitFile]: | ||
"""Parses xunit files.""" | ||
def parse(path: str) -> JUnitTreeOrException: | ||
"""Parses an xunit file and returns either a JUnitTree or an Exception.""" | ||
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) | ||
return transform_xunit_to_junit(trx) | ||
except BaseException as e: | ||
return e | ||
|
||
return [progress((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
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 |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
base=$(dirname "$0") | ||
|
||
python $base/../test_junit.py | ||
python $base/../test_xunit.py | ||
python $base/../test_trx.py | ||
|
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 @@ | ||
[mstest/fixie.xml](https://raw.githubusercontent.com/fixie/fixie/42b43dc6cc57476958eea8b507aa9d0d72cedae6/src/Fixie.Tests/Reports/XUnitXmlReport.xml) |
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,26 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<testsuites> | ||
<testsuite name="[assemblyLocation]" tests="7" failures="3" time="1.234" skipped="1" timestamp="YYYY-MM-DDTHH:MM:SS"> | ||
<testsuite name="[genericTestClass]" tests="3" failures="1" time="1.234" skipped="0"> | ||
<testcase name="ShouldBeString" time="1.234" classname="[genericTestClass]"/> | ||
<testcase name="ShouldBeString" time="1.234" classname="[genericTestClass]"/> | ||
<testcase name="ShouldBeString" time="1.234" classname="[genericTestClass]"> | ||
<failure type="Fixie.Tests.Assertions.AssertException" message="Expected: System.String Actual: System.Int32">Expected: System.String | ||
Actual: System.Int32 at [genericTestClassForStackTrace].ShouldBeString[T](T genericArgument) in [fileLocation]:line #</failure> | ||
</testcase> | ||
</testsuite> | ||
<testsuite name="[testClass]" tests="4" failures="2" time="1.234" skipped="1"> | ||
<testcase name="Fail" time="1.234" classname="[testClass]"> | ||
<failure type="Fixie.Tests.FailureException" message="'Fail' failed!">'Fail' failed! at [testClassForStackTrace].Fail() in [fileLocation]:line #</failure> | ||
</testcase> | ||
<testcase name="FailByAssertion" time="1.234" classname="[testClass]"> | ||
<failure type="Fixie.Tests.Assertions.AssertException" message="Expected: 2 Actual: 1">Expected: 2 | ||
Actual: 1 at [testClassForStackTrace].FailByAssertion() in [fileLocation]:line #</failure> | ||
</testcase> | ||
<testcase name="Pass" time="1.234" classname="[testClass]"/> | ||
<testcase name="Skip" time="1.234" classname="[testClass]"> | ||
<skipped message="⚠ Skipped with attribute."/> | ||
</testcase> | ||
</testsuite> | ||
</testsuite> | ||
</testsuites> |
Oops, something went wrong.