changeset 8:45d7bfe64d00

Slightly improved implementation of the python tools.
author cmlenz
date Thu, 09 Jun 2005 22:20:35 +0000
parents 8442bcb47a03
children 5d8457aa2025
files bitten/recipe/pythontools.py scripts/build.py
diffstat 2 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/recipe/pythontools.py
+++ b/bitten/recipe/pythontools.py
@@ -29,14 +29,18 @@
     pipe = Popen3(cmdline, capturestderr=True) # FIXME: Windows compatibility
     while True:
         retval = pipe.poll()
+        while True:
+            line = pipe.fromchild.readline()
+            if not line:
+                break
+            print '[distutils] %s' % line.rstrip()
+        while True:
+            line = pipe.childerr.readline()
+            if not line:
+                break
+            print '[distutils] %s' % line.rstrip()
         if retval != -1:
             break
-        line = pipe.fromchild.readline()
-        if line:
-            print '[distutils] %s' % line.rstrip()
-        line = pipe.childerr.readline()
-        if line:
-            print '[distutils] %s' % line.rstrip()
     if retval != 0:
         raise BuildError, "Executing distutils failed (%s)" % retval
 
@@ -53,6 +57,7 @@
             if filename.startswith(basedir):
                 filename = filename[len(basedir) + 1:]
             lineno = int(match.group('line'))
+            # TODO: emit to build master
 
 def trace(basedir, summary=None, coverdir=None, include=None, exclude=None):
     """Extract data from a `trac.py` run."""
@@ -62,3 +67,15 @@
 def unittest(basedir, file=None):
     """Extract data from a unittest results file in XML format."""
     assert file, 'Missing required attribute "file"'
+
+    from xml.dom import minidom
+    root = minidom.parse(open(file, 'r')).documentElement
+    assert root.tagName == 'unittest-results'
+    for test in root.getElementsByTagName('test'):
+        filename = test.getAttribute('file')
+        if filename.startswith(basedir):
+            filename = filename[len(basedir) + 1:]
+        duration = float(test.getAttribute('duration'))
+        name = test.getAttribute('name')
+        status = test.getAttribute('status')
+        # TODO: emit to build master
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -40,11 +40,12 @@
             steps_run.append(step.id)
 
     if step_id and not step_id in steps_run:
-        raise BuildError, "Recipe has no step named '%s'" % step_id
+        raise BuildError, 'Recipe has no step named "%s"' % step_id
 
 if __name__ == '__main__':
     try:
         build()
     except BuildError, e:
-        print>>sys.stderr, "FAILED: %s" % e
+        print>>sys.stderr, 'FAILED: %s' % e
         sys.exit(-1)
+    print 'SUCCESS'
Copyright (C) 2012-2017 Edgewall Software