Merge "xunit: support versions 3+"

This commit is contained in:
Zuul 2021-04-10 14:00:30 +00:00 committed by Gerrit Code Review
commit 10500593a0
10 changed files with 56 additions and 2 deletions

View File

@ -4694,6 +4694,9 @@ def xunit(registry, xml_parent, data):
:language: yaml
"""
info = registry.get_plugin_info("xunit")
plugin_version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
logger = logging.getLogger(__name__)
xunit = XML.SubElement(xml_parent, "org.jenkinsci.plugins.xunit.XUnitBuilder")
xunit.set("plugin", "xunit")
@ -4733,7 +4736,13 @@ def xunit(registry, xml_parent, data):
supported_types.append(configured_type)
# Generate XML for each of the supported framework types
xmltypes = XML.SubElement(xunit, "types")
# Note: versions 3+ are now using the 'tools' sub-element instead of 'types'
if plugin_version < pkg_resources.parse_version("3.0.0"):
types_name = "types"
else:
types_name = "tools"
xmltypes = XML.SubElement(xunit, types_name)
mappings = [
("pattern", "pattern", ""),
("requireupdate", "failIfNotNew", True),

View File

@ -1832,6 +1832,9 @@ def xunit(registry, xml_parent, data):
:language: yaml
"""
info = registry.get_plugin_info("xunit")
plugin_version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
logger = logging.getLogger(__name__)
xunit = XML.SubElement(xml_parent, "xunit")
xunit.set("plugin", "xunit")
@ -1871,7 +1874,13 @@ def xunit(registry, xml_parent, data):
supported_types.append(configured_type)
# Generate XML for each of the supported framework types
xmltypes = XML.SubElement(xunit, "types")
# Note: versions 3+ are now using the 'tools' sub-element instead of 'types'
if plugin_version < pkg_resources.parse_version("3.0.0"):
types_name = "types"
else:
types_name = "tools"
xmltypes = XML.SubElement(xunit, types_name)
for supported_type in supported_types:
framework_name = next(iter(supported_type.keys()))
xmlframework = XML.SubElement(xmltypes, types_to_plugin_types[framework_name])

View File

@ -0,0 +1 @@
../../publishers/fixtures/xunit001.plugins_info.yaml

View File

@ -0,0 +1 @@
../../publishers/fixtures/xunit001.plugins_info.yaml

View File

@ -0,0 +1,3 @@
- longName: 'xUnit'
shortName: 'xunit'
version: "2.4.0"

View File

@ -0,0 +1 @@
xunit001.plugins_info.yaml

View File

@ -0,0 +1 @@
xunit001.plugins_info.yaml

View File

@ -0,0 +1,3 @@
- longName: 'xUnit'
shortName: 'xunit'
version: "3.0.0"

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<xunit plugin="xunit">
<tools>
<PHPUnitJunitHudsonTestType>
<pattern>junit.log</pattern>
<failIfNotNew>true</failIfNotNew>
<deleteOutputFiles>true</deleteOutputFiles>
<skipNoTestFiles>false</skipNoTestFiles>
<stopProcessingIfError>true</stopProcessingIfError>
</PHPUnitJunitHudsonTestType>
</tools>
<thresholds/>
<thresholdMode>1</thresholdMode>
<extraConfiguration>
<testTimeMargin>3000</testTimeMargin>
</extraConfiguration>
</xunit>
</publishers>
</project>

View File

@ -0,0 +1,5 @@
publishers:
- xunit:
types:
- phpunit:
pattern: "junit.log"