Merge "Reformat xUnit publisher function and docstring help"
This commit is contained in:
commit
7e51c13c80
@ -911,44 +911,43 @@ def xunit(parser, xml_parent, data):
|
||||
Publish tests results. Requires the Jenkins :jenkins-wiki:`xUnit Plugin
|
||||
<xUnit+Plugin>`.
|
||||
|
||||
:arg str thresholdmode: whether thresholds represents an absolute \
|
||||
number of tests or a percentage. Either 'number' or 'percent', will \
|
||||
default to 'number' if omitted.
|
||||
:arg str thresholdmode: Whether thresholds represents an absolute number
|
||||
of tests or a percentage. Either 'number' or 'percent'. (default
|
||||
'number')
|
||||
:arg list thresholds: Thresholds for both 'failed' and 'skipped' tests.
|
||||
|
||||
:arg dict thresholds: list containing the thresholds for both \
|
||||
'failed' and 'skipped' tests. Each entry should in turn have a \
|
||||
list of "threshold name: values". The threshold names are \
|
||||
'unstable', 'unstablenew', 'failure', 'failurenew'. Omitting a \
|
||||
value will resort on xUnit default value (should be 0).
|
||||
:threshold (`dict`): Threshold values to set, where missing, xUnit
|
||||
should default to an internal value of 0. Each test threshold
|
||||
should contain the following:
|
||||
|
||||
:arg int test-time-margin: Give the report time margin value (default to \
|
||||
3000) in ms, before to fail if not new (unless the option 'Fail the build \
|
||||
if test results were not updated this run' is checked).
|
||||
* **unstable** (`int`)
|
||||
* **unstablenew** (`int`)
|
||||
* **failure** (`int`)
|
||||
* **failurenew** (`int`)
|
||||
|
||||
:arg dict types: per framework configuration. The key should be \
|
||||
one of the internal types we support:\
|
||||
'aunit', 'boosttest', 'checktype', 'cpptest', 'cppunit', 'ctest', \
|
||||
'embunit', 'fpcunit', 'gtest', 'junit', 'mstest', 'nunit', 'phpunit', \
|
||||
'tusar', 'unittest', 'valgrind'.
|
||||
:arg int test-time-margin: Give the report time margin value in ms, before
|
||||
to fail if not new unless the option **requireupdate** is set for the
|
||||
configured framework. (default 3000)
|
||||
:arg list types: Frameworks to configure, and options. Supports the
|
||||
following: ``aunit``, ``boosttest``, ``checktype``, ``cpptest``,
|
||||
``cppunit``, ``ctest``, ``embunit``, ``fpcunit``, ``gtest``, ``junit``,
|
||||
``mstest``, ``nunit``, ``phpunit``, ``tusar``, ``unittest``,
|
||||
and ``valgrind``.
|
||||
|
||||
The 'custom' type is not supported.
|
||||
|
||||
Each framework type can be configured using the following parameters:
|
||||
|
||||
:arg str pattern: An Ant pattern to look for Junit result files, \
|
||||
relative to the workspace root.
|
||||
|
||||
:arg bool requireupdate: fail the build whenever fresh tests \
|
||||
results have not been found (default: true).
|
||||
|
||||
:arg bool deleteoutput: delete temporary JUnit files (default: true)
|
||||
|
||||
:arg bool skip-if-no-test-files: Skip parsing this xUnit type report if \
|
||||
there are no test reports files (default: false).
|
||||
|
||||
:arg bool stoponerror: Fail the build whenever an error occur during \
|
||||
a result file processing (default: true).
|
||||
:type (`dict`): each type can be configured using the following:
|
||||
|
||||
* **pattern** (`str`): An Ant pattern to look for Junit result
|
||||
files, relative to the workspace root.
|
||||
* **requireupdate** (`bool`): fail the build whenever fresh tests
|
||||
results have not been found (default true).
|
||||
* **deleteoutput** (`bool`): delete temporary JUnit files
|
||||
(default true).
|
||||
* **skip-if-no-test-files** (`bool`): Skip parsing this xUnit type
|
||||
report if there are no test reports files (default false).
|
||||
* **stoponerror** (`bool`): Fail the build whenever an error occur
|
||||
during a result file processing (default true).
|
||||
|
||||
Example:
|
||||
|
||||
@ -1000,33 +999,28 @@ def xunit(parser, xml_parent, data):
|
||||
xmlframework = XML.SubElement(xmltypes,
|
||||
types_to_plugin_types[framework_name])
|
||||
|
||||
XML.SubElement(xmlframework, 'pattern').text = \
|
||||
supported_type[framework_name].get('pattern', '')
|
||||
XML.SubElement(xmlframework, 'failIfNotNew').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'requireupdate', True)).lower()
|
||||
XML.SubElement(xmlframework, 'deleteOutputFiles').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'deleteoutput', True)).lower()
|
||||
XML.SubElement(xmlframework, 'skipNoTestFiles').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'skip-if-no-test-files', False)).lower()
|
||||
XML.SubElement(xmlframework, 'stopProcessingIfError').text = \
|
||||
str(supported_type[framework_name].get(
|
||||
'stoponerror', True)).lower()
|
||||
XML.SubElement(xmlframework, 'pattern').text = (
|
||||
supported_type[framework_name].get('pattern', ''))
|
||||
XML.SubElement(xmlframework, 'failIfNotNew').text = str(
|
||||
supported_type[framework_name].get('requireupdate', True)).lower()
|
||||
XML.SubElement(xmlframework, 'deleteOutputFiles').text = str(
|
||||
supported_type[framework_name].get('deleteoutput', True)).lower()
|
||||
XML.SubElement(xmlframework, 'skipNoTestFiles').text = str(
|
||||
supported_type[framework_name].get('skip-if-no-test-files',
|
||||
False)).lower()
|
||||
XML.SubElement(xmlframework, 'stopProcessingIfError').text = str(
|
||||
supported_type[framework_name].get('stoponerror', True)).lower()
|
||||
|
||||
xmlthresholds = XML.SubElement(xunit, 'thresholds')
|
||||
if 'thresholds' in data:
|
||||
for t in data['thresholds']:
|
||||
for t in data.get('thresholds', []):
|
||||
if not ('failed' in t or 'skipped' in t):
|
||||
logger.warn(
|
||||
"Unrecognized threshold, should be 'failed' or 'skipped'")
|
||||
continue
|
||||
elname = "org.jenkinsci.plugins.xunit.threshold.%sThreshold" \
|
||||
% next(iter(t.keys())).title()
|
||||
elname = ("org.jenkinsci.plugins.xunit.threshold.%sThreshold" %
|
||||
next(iter(t.keys())).title())
|
||||
el = XML.SubElement(xmlthresholds, elname)
|
||||
for threshold_name, threshold_value in \
|
||||
next(iter(t.values())).items():
|
||||
for threshold_name, threshold_value in next(iter(t.values())).items():
|
||||
# Normalize and craft the element name for this threshold
|
||||
elname = "%sThreshold" % threshold_name.lower().replace(
|
||||
'new', 'New')
|
||||
@ -1039,12 +1033,11 @@ def xunit(parser, xml_parent, data):
|
||||
thresholdmode = '1'
|
||||
if 'percent' == data.get('thresholdmode', 'number'):
|
||||
thresholdmode = '2'
|
||||
XML.SubElement(xunit, 'thresholdMode').text = \
|
||||
thresholdmode
|
||||
XML.SubElement(xunit, 'thresholdMode').text = thresholdmode
|
||||
|
||||
extra_config = XML.SubElement(xunit, 'extraConfiguration')
|
||||
XML.SubElement(extra_config, 'testTimeMargin').text = \
|
||||
str(data.get('test-time-margin', '3000'))
|
||||
XML.SubElement(extra_config, 'testTimeMargin').text = str(
|
||||
data.get('test-time-margin', '3000'))
|
||||
|
||||
|
||||
def _violations_add_entry(xml_parent, name, data):
|
||||
|
Loading…
Reference in New Issue
Block a user