From 81781a4aa869f7a6140a3a0a802d9a1674fef321 Mon Sep 17 00:00:00 2001 From: Lucas Dutra Nunes Date: Mon, 17 Nov 2014 10:27:59 -0200 Subject: [PATCH] xUnit publisher: add option to skip if there are no tests files This is valid for each defined xUnit type publisher on the job. Default is false. Change-Id: Idff3c8ba6a4e4291ec483b2eb4a999dcbeea7291 Signed-off-by: Lucas Dutra Nunes --- jenkins_jobs/modules/publishers.py | 6 ++++++ tests/publishers/fixtures/xunit001.xml | 2 ++ tests/publishers/fixtures/xunit002.xml | 1 + tests/publishers/fixtures/xunit002.yaml | 1 + 4 files changed, 10 insertions(+) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 9782b201d..8d7fecabe 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -875,6 +875,9 @@ def xunit(parser, xml_parent, data): :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). @@ -936,6 +939,9 @@ def xunit(parser, xml_parent, data): 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() diff --git a/tests/publishers/fixtures/xunit001.xml b/tests/publishers/fixtures/xunit001.xml index bd29c7fe3..037da0275 100644 --- a/tests/publishers/fixtures/xunit001.xml +++ b/tests/publishers/fixtures/xunit001.xml @@ -7,12 +7,14 @@ junit.log true true + false true cppunit.log true true + false true diff --git a/tests/publishers/fixtures/xunit002.xml b/tests/publishers/fixtures/xunit002.xml index db7064a00..3b648b94f 100644 --- a/tests/publishers/fixtures/xunit002.xml +++ b/tests/publishers/fixtures/xunit002.xml @@ -7,6 +7,7 @@ build/tests/reports/ctest.xml true true + true true diff --git a/tests/publishers/fixtures/xunit002.yaml b/tests/publishers/fixtures/xunit002.yaml index a4517cbc1..0f1c2c129 100644 --- a/tests/publishers/fixtures/xunit002.yaml +++ b/tests/publishers/fixtures/xunit002.yaml @@ -16,3 +16,4 @@ publishers: types: - ctest: pattern: "build/tests/reports/ctest.xml" + skip-if-no-test-files: true