changeset 105:de5b6e69fc7e

* Make the {{{unittest}}} command raise an exception if the tests failed, so that distutils exits with a non-zero return code. * Slightly improved for recipe execution.
author cmlenz
date Wed, 20 Jul 2005 17:13:45 +0000
parents 4bee62474361
children 88869d08ea2a
files bitten/build/ctools.py bitten/build/pythontools.py bitten/util/cmdline.py bitten/util/testrunner.py
diffstat 4 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/ctools.py
+++ b/bitten/build/ctools.py
@@ -36,4 +36,4 @@
         ctxt.log(ctxt.OUTPUT, out)
         ctxt.log(ctxt.ERROR, err)
     if cmdline.returncode != 0:
-        raise BuildError, "Executing make failed (%s)" % cmdline.returncode
+        raise BuildError, 'make failed (%s)' % cmdline.returncode
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -30,7 +30,7 @@
         ctxt.log(ctxt.OUTPUT, out)
         ctxt.log(ctxt.ERROR, err)
     if cmdline.returncode != 0:
-        raise BuildError, 'Executing distutils failed (%s)' % cmdline.returncode
+        raise BuildError, 'distutils failed (%s)' % cmdline.returncode
 
 def pylint(ctxt, file=None):
     """Extract data from a `pylint` run written to a file."""
--- a/bitten/util/cmdline.py
+++ b/bitten/util/cmdline.py
@@ -66,6 +66,7 @@
             err_name = tempfile.mktemp()
             cmd = "( %s ) > %s 2> %s" % (' '.join(args), out_name, err_name)
             self.returncode = os.system(cmd) >> 8
+            log.debug('Exited with code %s', self.returncode)
 
             out_file = file(out_name, 'r')
             err_file = file(err_name, 'r')
@@ -124,6 +125,7 @@
                     yield out_line, err_line
                 time.sleep(.1)
             self.returncode = pipe.wait()
+            log.debug('Exited with code %s', self.returncode)
 
     def _combine(self, *iterables):
         iterables = [iter(iterable) for iterable in iterables]
--- a/bitten/util/testrunner.py
+++ b/bitten/util/testrunner.py
@@ -61,8 +61,8 @@
 
 class XMLTestRunner(TextTestRunner):
 
-    def __init__(self, stream=sys.stderr, xml_stream=None):
-        TextTestRunner.__init__(self, stream, descriptions=0, verbosity=1)
+    def __init__(self, stream=sys.stdout, xml_stream=None):
+        TextTestRunner.__init__(self, stream, descriptions=0, verbosity=2)
         self.xml_stream = xml_stream
 
     def _makeResult(self):
@@ -148,5 +148,7 @@
         suite = __import__(self.test_suite)
         for comp in self.test_suite.split('.')[1:]:
             suite = getattr(suite, comp)
-        runner = XMLTestRunner(stream=sys.stderr, xml_stream=self.xml_results)
-        runner.run(suite.suite())
+        runner = XMLTestRunner(stream=sys.stdout, xml_stream=self.xml_results)
+        result = runner.run(suite.suite())
+        if result.failures or result.errors:
+            raise DistutilsExecError, 'unit tests failed'
Copyright (C) 2012-2017 Edgewall Software