From 624fd659ccf158ffcded171760d0eaa2a32ae049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Sat, 29 Jun 2013 04:31:50 +0200 Subject: [PATCH] Add TAP test result handling ability Add support for using org.tap4j.plugin.TapPublisher as a publisher "tap" See https://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin for the plugin in question Change-Id: Iddbd96715830ecc761384963fecfe3cd5ec3c115 Reviewed-on: https://review.openstack.org/34974 Reviewed-by: Khai Do Reviewed-by: James E. Blair Approved: Clark Boylan Reviewed-by: Clark Boylan Tested-by: Jenkins --- jenkins_jobs/modules/publishers.py | 48 ++++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 49 insertions(+) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 82f5d3b62..dbb259978 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1759,6 +1759,54 @@ def maven_deploy(parser, xml_parent, data): data.get('deploy-unstable', 'false')).lower() +def tap(parser, xml_parent, data): + """yaml: tap + Adds support to TAP test result files + + See `TAP Plugin. + `_ + + :arg str results: TAP test result files + :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) + :arg bool output-tap-to-console: Output tap to console (default True) + :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) + + + Example:: + + publishers: + - tap: + results: puiparts.tap + todo-is-failure: false + """ + + tap = XML.SubElement(xml_parent, 'org.tap4j.plugin.TapPublisher') + + 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() + + class Publishers(jenkins_jobs.modules.base.Base): sequence = 70 diff --git a/setup.py b/setup.py index 7b59fa2c8..8cf782a53 100644 --- a/setup.py +++ b/setup.py @@ -133,6 +133,7 @@ setuptools.setup( 'workspace-cleanup=jenkins_jobs.modules.publishers:' 'workspace_cleanup', 'maven-deploy=jenkins_jobs.modules.publishers:maven_deploy', + 'tap=jenkins_jobs.modules.publishers:tap', ], 'jenkins_jobs.scm': [ 'git=jenkins_jobs.modules.scm:git',