From 1cf55db557cadae9dc55fbeda5ed21b9386fc5bc Mon Sep 17 00:00:00 2001 From: Lukas Bednar Date: Thu, 12 Nov 2015 13:20:40 +0100 Subject: [PATCH] publishers: xunit doesn't accepts integers as threshold * Accept integers for threshold In documentation is written that threshold should be integer. But it fails with integer to generate XML. Only case when it pass is for 0, because XML formatter consider it as empty body and do not format it. * Fix documentation for missing threshold field, plus test. In documentation it says that missing threshold is set to 0, but apparently it is set to Null (empty field), and it has different behaviour than for 0 value. Change-Id: I326cbadd955c4c28f315fa72293d9a54a116b140 --- jenkins_jobs/modules/publishers.py | 2 +- tests/publishers/fixtures/xunit001.xml | 16 ++++++------- tests/publishers/fixtures/xunit002.yaml | 16 ++++++------- tests/publishers/fixtures/xunit003.xml | 30 +++++++++++++++++++++++++ tests/publishers/fixtures/xunit003.yaml | 12 ++++++++++ 5 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 tests/publishers/fixtures/xunit003.xml create mode 100644 tests/publishers/fixtures/xunit003.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 25025dd1e..5c68392d8 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1103,7 +1103,7 @@ def xunit(parser, xml_parent, data): # Normalize and craft the element name for this threshold elname = "%sThreshold" % threshold_name.lower().replace( 'new', 'New') - XML.SubElement(el, elname).text = threshold_value + XML.SubElement(el, elname).text = str(threshold_value) # Whether to use percent of exact number of tests. # Thresholdmode is either: diff --git a/tests/publishers/fixtures/xunit001.xml b/tests/publishers/fixtures/xunit001.xml index 735737bcf..1999e1276 100644 --- a/tests/publishers/fixtures/xunit001.xml +++ b/tests/publishers/fixtures/xunit001.xml @@ -27,16 +27,16 @@ - - - - + 0 + 0 + 0 + 0 - - - - + 0 + 0 + 0 + 0 2 diff --git a/tests/publishers/fixtures/xunit002.yaml b/tests/publishers/fixtures/xunit002.yaml index 0f1c2c129..f7183daeb 100644 --- a/tests/publishers/fixtures/xunit002.yaml +++ b/tests/publishers/fixtures/xunit002.yaml @@ -4,15 +4,15 @@ publishers: thresholdmode: 'number' thresholds: - failed: - unstable: '1' - unstablenew: '2' - failure: '3' - failurenew: '4' + unstable: 1 + unstablenew: 2 + failure: 3 + failurenew: 4 - skipped: - unstable: '5' - unstablenew: '6' - failure: '7' - failurenew: '8' + unstable: 5 + unstablenew: 6 + failure: 7 + failurenew: 8 types: - ctest: pattern: "build/tests/reports/ctest.xml" diff --git a/tests/publishers/fixtures/xunit003.xml b/tests/publishers/fixtures/xunit003.xml new file mode 100644 index 000000000..f214c7c35 --- /dev/null +++ b/tests/publishers/fixtures/xunit003.xml @@ -0,0 +1,30 @@ + + + + + + + junit.log + true + true + false + true + + + + + 10 + 5 + + + 5 + 10 + + + 1 + + 3000 + + + + diff --git a/tests/publishers/fixtures/xunit003.yaml b/tests/publishers/fixtures/xunit003.yaml new file mode 100644 index 000000000..a8f7043ae --- /dev/null +++ b/tests/publishers/fixtures/xunit003.yaml @@ -0,0 +1,12 @@ +publishers: + - xunit: + thresholds: + - failed: + unstable: 10 + failure: 5 + - skipped: + unstablenew: 5 + failurenew: 10 + types: + - phpunit: + pattern: "junit.log"