# HG changeset patch # User cmlenz # Date 1123490107 0 # Node ID 77dd69f7c405bb5df63c4a9930ed428226fd920d # Parent 2f0f2f0065269a315187c1bf32718063ebd2ae70 * Make the recipe command {{{}}} transmit the test results to the build master. Closes #32. * Make report data retrieved from the store accessible as {{{xmlio.ParsedElement}}}. diff --git a/bitten/build/pythontools.py b/bitten/build/pythontools.py --- a/bitten/build/pythontools.py +++ b/bitten/build/pythontools.py @@ -91,17 +91,10 @@ try: fd = open(ctxt.resolve(file), 'r') try: - from xml.dom import minidom - root = minidom.parse(fd).documentElement - assert root.tagName == 'unittest-results' - for test in root.getElementsByTagName('test'): - filename = test.getAttribute('file') - if filename.startswith(ctxt.basedir): - filename = filename[len(ctxt.basedir) + 1:] - duration = float(test.getAttribute('duration')) - name = test.getAttribute('name') - status = test.getAttribute('status') - # TODO: emit to build master + results = xmlio.Fragment() + for child in xmlio.parse(fd).children(): + results.append(child) + ctxt.report(results) finally: fd.close() except IOError, e: diff --git a/bitten/store.py b/bitten/store.py --- a/bitten/store.py +++ b/bitten/store.py @@ -22,6 +22,7 @@ import os from trac.core import * +from bitten.util import xmlio log = logging.getLogger('bitten.store') @@ -73,15 +74,15 @@ ] - class XmlValueWrapper(object): + class XmlValueWrapper(xmlio.ParsedElement): _metadata = None def __init__(self, value): self.value = value - - def __str__(self): - return self.value.asString() + from xml.dom import minidom + dom = minidom.parseString(value.asString()) + xmlio.ParsedElement.__init__(self, dom.documentElement) def _get_metadata(self): if self._metadata is None: diff --git a/bitten/util/xmlio.py b/bitten/util/xmlio.py --- a/bitten/util/xmlio.py +++ b/bitten/util/xmlio.py @@ -72,7 +72,7 @@ stream. """ for child in self.children: - if isinstance(child, Element): + if isinstance(child, (Element, ParsedElement)): child.write(out, newlines=newlines) else: if child[0] == '<':