From 4c7c362318971ef7682244b09b8f5c4f0a9918d3 Mon Sep 17 00:00:00 2001 From: Kien Ha Date: Thu, 7 Jul 2016 19:41:43 -0400 Subject: [PATCH] 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 --- jenkins_jobs/modules/publishers.py | 55 +++++++++++++--------- tests/publishers/fixtures/tap-full.xml | 19 ++++++++ tests/publishers/fixtures/tap-full.yaml | 14 ++++++ tests/publishers/fixtures/tap-minimal.xml | 19 ++++++++ tests/publishers/fixtures/tap-minimal.yaml | 3 ++ tests/publishers/fixtures/tap001.xml | 7 ++- 6 files changed, 94 insertions(+), 23 deletions(-) create mode 100644 tests/publishers/fixtures/tap-full.xml create mode 100644 tests/publishers/fixtures/tap-full.yaml create mode 100644 tests/publishers/fixtures/tap-minimal.xml create mode 100644 tests/publishers/fixtures/tap-minimal.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 1a583bfa2..433b39c28 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3071,7 +3071,7 @@ def tap(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`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): diff --git a/tests/publishers/fixtures/tap-full.xml b/tests/publishers/fixtures/tap-full.xml new file mode 100644 index 000000000..7ee7222ca --- /dev/null +++ b/tests/publishers/fixtures/tap-full.xml @@ -0,0 +1,19 @@ + + + + + puiparts.tap + true + true + false + false + true + false + true + true + false + false + true + + + diff --git a/tests/publishers/fixtures/tap-full.yaml b/tests/publishers/fixtures/tap-full.yaml new file mode 100644 index 000000000..b86e3ec00 --- /dev/null +++ b/tests/publishers/fixtures/tap-full.yaml @@ -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 diff --git a/tests/publishers/fixtures/tap-minimal.xml b/tests/publishers/fixtures/tap-minimal.xml new file mode 100644 index 000000000..d6e1d0936 --- /dev/null +++ b/tests/publishers/fixtures/tap-minimal.xml @@ -0,0 +1,19 @@ + + + + + puiparts.tap + false + false + true + true + false + true + false + false + true + true + false + + + diff --git a/tests/publishers/fixtures/tap-minimal.yaml b/tests/publishers/fixtures/tap-minimal.yaml new file mode 100644 index 000000000..f3562caff --- /dev/null +++ b/tests/publishers/fixtures/tap-minimal.yaml @@ -0,0 +1,3 @@ +publishers: + - tap: + results: puiparts.tap diff --git a/tests/publishers/fixtures/tap001.xml b/tests/publishers/fixtures/tap001.xml index 4ac719752..390f234ba 100644 --- a/tests/publishers/fixtures/tap001.xml +++ b/tests/publishers/fixtures/tap001.xml @@ -1,7 +1,7 @@ - + puiparts.tap false false @@ -9,6 +9,11 @@ true false false + false + false + true + true + false