Index: jhbuild/config.py
===================================================================
RCS file: /cvs/gnome/jhbuild/jhbuild/config.py,v
retrieving revision 1.25
diff -U5 -r1.25 config.py
--- jhbuild/config.py	19 Jun 2006 14:07:25 -0000	1.25
+++ jhbuild/config.py	12 Jul 2006 09:28:59 -0000
@@ -32,11 +32,11 @@
                 'repos', 'branches',
                 'builddir_pattern', 'module_autogenargs', 'module_makeargs',
                 'interact', 'buildscript', 'nonetwork',
                 'alwaysautogen', 'nobuild', 'makeclean', 'makecheck',
                 'use_lib64', 'tinderbox_outputdir', 'sticky_date',
-                'tarballdir', 'pretty_print' ]
+                'tarballdir', 'pretty_print', 'unittestfails' ]
 
 env_prepends = {}
 def prependpath(envvar, path):
     env_prepends.setdefault(envvar, []).append(path)
 
Index: jhbuild/defaults.jhbuildrc
===================================================================
RCS file: /cvs/gnome/jhbuild/jhbuild/defaults.jhbuildrc,v
retrieving revision 1.19
diff -U5 -r1.19 defaults.jhbuildrc
--- jhbuild/defaults.jhbuildrc	17 May 2006 12:03:26 -0000	1.19
+++ jhbuild/defaults.jhbuildrc	12 Jul 2006 09:28:59 -0000
@@ -43,10 +43,11 @@
 nobuild       = False  # don't actually build the packages
 makeclean     = False  # run make clean before building
 makecheck     = False  # run make check after building
 
 interact      = True   # whether to interact with the user.
+unittestfails = True   # whether unit tests failures make build fail
 
 # whether to install to lib64 directories?  Currently this will default to
 # True on Linux AMD64, PPC64 or S390x systems, and False everywhere else.
 # Patches accepted to fix the default for other architectures.
 uname = os.uname()
Index: jhbuild/errors.py
===================================================================
RCS file: /cvs/gnome/jhbuild/jhbuild/errors.py,v
retrieving revision 1.4
diff -U5 -r1.4 errors.py
--- jhbuild/errors.py	12 May 2006 08:04:53 -0000	1.4
+++ jhbuild/errors.py	12 Jul 2006 09:28:59 -0000
@@ -37,5 +37,8 @@
         Exception.__init__(self, message)
         self.returncode = returncode
 
 class BuildStateError(Exception):
     '''An error occurred while processing a build state.'''
+
+class TestsFailedError(Exception):
+    '''Unit tests have failed.'''
Index: jhbuild/modtypes/__init__.py
===================================================================
RCS file: /cvs/gnome/jhbuild/jhbuild/modtypes/__init__.py,v
retrieving revision 1.9
diff -U5 -r1.9 __init__.py
--- jhbuild/modtypes/__init__.py	14 Jun 2006 02:35:55 -0000	1.9
+++ jhbuild/modtypes/__init__.py	12 Jul 2006 09:28:59 -0000
@@ -25,11 +25,11 @@
     'Package',
     'get_dependencies'
     'get_branch'
     ]
 
-from jhbuild.errors import FatalError, CommandError, BuildStateError
+from jhbuild.errors import FatalError, CommandError, BuildStateError, TestsFailedError
 
 _module_types = {}
 def register_module_type(name, parse_func):
     _module_types[name] = parse_func
 
@@ -153,10 +153,18 @@
             try:
                 method(buildscript)
             except (CommandError, BuildStateError), e:
                 return (self._next_state(buildscript, state),
                         str(e), method.error_states)
+            except TestsFailedError, e:
+                if buildscript.config.unittestfails:
+                    return (self._next_state(buildscript, state),
+                            str(e), method.error_states)
+                else:
+                    buildscript.message('Unit tests failed')
+                    return (self._next_state(buildscript, state),
+                            None, None)
             else:
                 return (self._next_state(buildscript, state),
                         None, None)
         else:
             return method(buildscript)
Index: jhbuild/modtypes/autotools.py
===================================================================
RCS file: /cvs/gnome/jhbuild/jhbuild/modtypes/autotools.py,v
retrieving revision 1.9
diff -U5 -r1.9 autotools.py
--- jhbuild/modtypes/autotools.py	23 Jun 2006 07:47:53 -0000	1.9
+++ jhbuild/modtypes/autotools.py	12 Jul 2006 09:28:59 -0000
@@ -19,11 +19,11 @@
 
 __metaclass__ = type
 
 import os
 
-from jhbuild.errors import FatalError, BuildStateError
+from jhbuild.errors import FatalError, BuildStateError, TestsFailedError, CommandError
 from jhbuild.modtypes import \
      Package, get_dependencies, get_branch, register_module_type
 
 __all__ = [ 'AutogenModule' ]
 
@@ -166,11 +166,14 @@
                 buildscript.config.nobuild)
 
     def do_check(self, buildscript):
         buildscript.set_action('Checking', self)
         cmd = '%s %s check' % (os.environ.get('MAKE', 'make'), self.makeargs)
-        buildscript.execute(cmd, cwd=self.get_builddir(buildscript))
+        try:
+            buildscript.execute(cmd, cwd=self.get_builddir(buildscript))
+        except CommandError:
+            raise TestsFailedError ('Unit tests have failed')
     do_check.next_state = STATE_INSTALL
     do_check.error_states = [STATE_FORCE_CHECKOUT, STATE_CONFIGURE]
 
     def skip_install(self, buildscript, last_state):
         return buildscript.config.nobuild
