Open zerkms opened 3 years ago
UPD: I believe this would be the jenkins' junit xsd: https://github.com/junit-team/junit5/blob/main/platform-tests/src/test/resources/jenkins-junit.xsd
As far as I can tell, Jenkins is expecting a root <testsuites>
element, which then contains individual <testsuite>
elements.
I have borrowed the core of the solution https://github.com/xmlrunner/unittest-xml-reporting/blob/master/xmlrunner/extra/xunit_plugin.py does in the similar case with a little alteration.
The transform that makes mypy report valid for me looks like this
TRANSFORM = etree.XSLT(etree.XML(b'''\
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<!-- /dev/null for these attributes -->
<xsl:template match="//testcase/@file" />
<xsl:template match="//testcase/@line" />
<xsl:template match="//testcase/@timestamp" />
<xsl:template match="@skips">
<xsl:attribute name="skipped">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<!-- copy the rest -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>'''))
Which does the same as the xmlrunner one + a rename of skips
attribute to skipped
.
Given the discussion on https://github.com/python/mypy/issues/4233 indicated that it would be preferable to move the XML output generation to external tools, is this issue like to be worked on? (I don't mind if it is, however if it does get fixed then I'd vote for re-opening & fixing https://github.com/python/mypy/issues/4233 too).
Alternatively, perhaps it's time to just remove the --junit-xml
flag and point people to other tools for their XML needs? (I've personally found that https://pypi.org/project/mypy2junit/ works better than --junit-xml
, there may be others)
Bug Report
It looks like the current stable
mypy-0.800-cp36-cp36m-manylinux2010_x86_64.whl
does not generate a "valid" junit compatible file as jenkins treats it. I know that the junit format is not really standardised, but I think it would be cool if the file generated was jenkins compatible (or may be a little tool was provided that converts the "incorrect" format to a "correct" one).An example of a file that fails in jenkins is
and the corresponding stacktrace:
To Reproduce
(Write your steps here:)
--junit-xml
Expected Behavior
(Write what you thought would happen.)
Actual Behavior
(Write what happened.)
Your Environment
mypy.ini
(and other config files):