mirror of
https://github.com/apache/impala.git
synced 2025-12-19 09:58:28 -05:00
IMPALA-8193: Fix python 2.6 issue in junit_prune_notrun.py
Python 2.6's ElementTree.write() does not have an xml_declaration argument, so junitxml_prune_notrun.py fails on python 2.6. This fixes junitxml_prune_notrun.py by using minidom to write the output. This mirrors how bin/generate_junitxml.py outputs XML. Verified that tests now pass on python 2.6 and python 2.7 does not change. Change-Id: I9ef8fb77b1ac8c51e3dfb6b04690ae9ccc490d62 Reviewed-on: http://gerrit.cloudera.org:8080/12479 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
f4dd98236a
commit
4344914bb3
@@ -22,11 +22,12 @@ Some tests that produce JUnitXML include tests that did not run (i.e. status="no
|
||||
This script walks through the JUnitXML and removes these elements.
|
||||
"""
|
||||
from optparse import OptionParser
|
||||
from xml.etree.ElementTree import ElementTree
|
||||
from xml.etree import ElementTree as ET
|
||||
from xml.dom import minidom
|
||||
|
||||
|
||||
def junitxml_prune_notrun(junitxml_filename):
|
||||
tree = ElementTree()
|
||||
tree = ET.ElementTree()
|
||||
root = tree.parse(junitxml_filename)
|
||||
|
||||
for testsuite in root.findall("testsuite"):
|
||||
@@ -52,7 +53,12 @@ def junitxml_prune_notrun(junitxml_filename):
|
||||
# Fixup the total number of tests
|
||||
testsuite.attrib["tests"] = str(num_tests - len(notrun_testcases))
|
||||
# Write out the pruned JUnitXML
|
||||
tree.write(junitxml_filename, encoding="utf-8", xml_declaration=True)
|
||||
# An XML declaration is optional, but it is nice to have. ElementTree.write() does
|
||||
# not support an XML declaration on Python 2.6, so use minidom to write the XML.
|
||||
root_node_minidom = minidom.parseString(ET.tostring(root))
|
||||
junitxml_string = root_node_minidom.toxml(encoding="utf-8")
|
||||
with open(junitxml_filename, "w") as f:
|
||||
f.write(junitxml_string)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user