# HG changeset patch # User cmlenz # Date 1121879625 0 # Node ID de5b6e69fc7e4d44278b32a0d6c8fc0031bf936d # Parent 4bee62474361aa530c92b926679bc742a9d69e13 * 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. diff --git a/bitten/build/ctools.py b/bitten/build/ctools.py --- 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 diff --git a/bitten/build/pythontools.py b/bitten/build/pythontools.py --- 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.""" diff --git a/bitten/util/cmdline.py b/bitten/util/cmdline.py --- 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] diff --git a/bitten/util/testrunner.py b/bitten/util/testrunner.py --- 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'