Merge "Reformat xUnit publisher function and docstring help"

This commit is contained in:
Jenkins 2015-08-10 18:39:27 +00:00 committed by Gerrit Code Review
commit 7e51c13c80

View File

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