Update TAP plugin

- Add support for new options
- Add minimal and full tests
- Update to use convert_mapping_to_xml
- Update doc options to have default values
- Add plugin="tap" attribute

Change-Id: If53a16a04a0ef79e2458df00f40cefb978ddc56b
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-07 19:41:43 -04:00
parent 1c22158672
commit 4c7c362318
6 changed files with 94 additions and 23 deletions

View File

@ -3071,7 +3071,7 @@ def tap(parser, xml_parent, data):
Requires the Jenkins :jenkins-wiki:`TAP Plugin <TAP+Plugin>`.
:arg str results: TAP test result files
:arg str results: TAP test result files (required)
:arg bool fail-if-no-results: Fail if no result (default false)
:arg bool failed-tests-mark-build-as-failure:
Mark build as failure if test fails (default false)
@ -3079,35 +3079,46 @@ def tap(parser, xml_parent, data):
:arg bool enable-subtests: Enable subtests (default true)
:arg bool discard-old-reports: Discard old reports (default false)
:arg bool todo-is-failure: Handle TODO's as failures (default true)
:arg bool include-comment-diagnostics: Include comment diagnostics (#) in
the results table (>=1.12) (default false)
:arg bool validate-tests: Validate number of tests (>=1.13) (default false)
:arg bool plan-required: TAP plan required? (>=1.17) (default true)
:arg bool verbose: Print a message for each TAP stream file (>=1.17)
(default true)
:arg bool show-only-failures: show only test failures (>=1.17)
(default false)
Full Example:
Example:
.. literalinclude:: /../../tests/publishers/fixtures/tap-full.yaml
:language: yaml
.. literalinclude:: /../../tests/publishers/fixtures/tap001.yaml
Minimal Example:
.. literalinclude:: /../../tests/publishers/fixtures/tap-minimal.yaml
:language: yaml
"""
tap = XML.SubElement(xml_parent, 'org.tap4j.plugin.TapPublisher')
tap.set('plugin', 'tap')
XML.SubElement(tap, 'testResults').text = data['results']
XML.SubElement(tap, 'failIfNoResults').text = str(
data.get('fail-if-no-results', False)).lower()
XML.SubElement(tap, 'failedTestsMarkBuildAsFailure').text = str(
data.get('failed-tests-mark-build-as-failure', False)).lower()
XML.SubElement(tap, 'outputTapToConsole').text = str(
data.get('output-tap-to-console', True)).lower()
XML.SubElement(tap, 'enableSubtests').text = str(
data.get('enable-subtests', True)).lower()
XML.SubElement(tap, 'discardOldReports').text = str(
data.get('discard-old-reports', False)).lower()
XML.SubElement(tap, 'todoIsFailure').text = str(
data.get('todo-is-failure', True)).lower()
mappings = [
('results', 'testResults', None),
('fail-if-no-results', 'failIfNoResults', False),
('failed-tests-mark-build-as-failure',
'failedTestsMarkBuildAsFailure',
False),
('output-tap-to-console', 'outputTapToConsole', True),
('enable-subtests', 'enableSubtests', True),
('discard-old-reports', 'discardOldReports', False),
('todo-is-failure', 'todoIsFailure', True),
('include-comment-diagnostics', 'includeCommentDiagnostics', False),
('validate-tests', 'validateNumberOfTests', False),
('plan-required', 'planRequired', True),
('verbose', 'verbose', True),
('show-only-failures', 'showOnlyFailures', False),
]
helpers.convert_mapping_to_xml(tap, data, mappings, fail_required=True)
def post_tasks(parser, xml_parent, data):

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<org.tap4j.plugin.TapPublisher plugin="tap">
<testResults>puiparts.tap</testResults>
<failIfNoResults>true</failIfNoResults>
<failedTestsMarkBuildAsFailure>true</failedTestsMarkBuildAsFailure>
<outputTapToConsole>false</outputTapToConsole>
<enableSubtests>false</enableSubtests>
<discardOldReports>true</discardOldReports>
<todoIsFailure>false</todoIsFailure>
<includeCommentDiagnostics>true</includeCommentDiagnostics>
<validateNumberOfTests>true</validateNumberOfTests>
<planRequired>false</planRequired>
<verbose>false</verbose>
<showOnlyFailures>true</showOnlyFailures>
</org.tap4j.plugin.TapPublisher>
</publishers>
</project>

View File

@ -0,0 +1,14 @@
publishers:
- tap:
results: puiparts.tap
fail-if-no-results: true
failed-tests-mark-build-as-failure: true
output-tap-to-console: false
enable-subtests: false
discard-old-reports: true
todo-is-failure: false
include-comment-diagnostics: true
validate-tests: true
plan-required: false
verbose: false
show-only-failures: true

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<org.tap4j.plugin.TapPublisher plugin="tap">
<testResults>puiparts.tap</testResults>
<failIfNoResults>false</failIfNoResults>
<failedTestsMarkBuildAsFailure>false</failedTestsMarkBuildAsFailure>
<outputTapToConsole>true</outputTapToConsole>
<enableSubtests>true</enableSubtests>
<discardOldReports>false</discardOldReports>
<todoIsFailure>true</todoIsFailure>
<includeCommentDiagnostics>false</includeCommentDiagnostics>
<validateNumberOfTests>false</validateNumberOfTests>
<planRequired>true</planRequired>
<verbose>true</verbose>
<showOnlyFailures>false</showOnlyFailures>
</org.tap4j.plugin.TapPublisher>
</publishers>
</project>

View File

@ -0,0 +1,3 @@
publishers:
- tap:
results: puiparts.tap

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<org.tap4j.plugin.TapPublisher>
<org.tap4j.plugin.TapPublisher plugin="tap">
<testResults>puiparts.tap</testResults>
<failIfNoResults>false</failIfNoResults>
<failedTestsMarkBuildAsFailure>false</failedTestsMarkBuildAsFailure>
@ -9,6 +9,11 @@
<enableSubtests>true</enableSubtests>
<discardOldReports>false</discardOldReports>
<todoIsFailure>false</todoIsFailure>
<includeCommentDiagnostics>false</includeCommentDiagnostics>
<validateNumberOfTests>false</validateNumberOfTests>
<planRequired>true</planRequired>
<verbose>true</verbose>
<showOnlyFailures>false</showOnlyFailures>
</org.tap4j.plugin.TapPublisher>
</publishers>
</project>