changeset 3172:d1b367fc08bc tests-returncode

Use a return code of 1 when the tests fail.
author Thomas Kluyver <takowl@gmail.com>
date Wed, 09 Jan 2013 10:13:57 +0000
parents 17bf68ccad37
children 16b51ab472f2
files test/__main__.py test/test_utils/run_tests.py
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/__main__.py	Tue Jan 08 14:05:02 2013 +0100
+++ b/test/__main__.py	Wed Jan 09 10:13:57 2013 +0000
@@ -26,10 +26,10 @@
     is_pygame_pkg = __name__.startswith('pygame.tests.')
 
 if is_pygame_pkg:
-    from pygame.tests.test_utils.run_tests import run
+    from pygame.tests.test_utils.run_tests import run_and_exit
     from pygame.tests.test_utils.test_runner import opt_parser
 else:
-    from test.test_utils.run_tests import run
+    from test.test_utils.run_tests import run_and_exit
     from test.test_utils.test_runner import opt_parser
 
 if is_pygame_pkg:
@@ -128,6 +128,6 @@
 
 ###########################################################################
 # Run the test suite.
-run(*args, **kwds)
+run_and_exit(*args, **kwds)
 
 
--- a/test/test_utils/run_tests.py	Tue Jan 08 14:05:02 2013 +0100
+++ b/test/test_utils/run_tests.py	Wed Jan 09 10:13:57 2013 +0000
@@ -317,5 +317,15 @@
 
     return total, fails
 
-###############################################################################
 
+def run_and_exit(*args, **kwargs):
+    """Run the tests, and if there are failures, exit with a return code of 1.
+    
+    This is needed for various buildbots to recognise that the tests have
+    failed.
+    """
+    total, fails = run(*args, **kwargs)
+    if fails:
+        sys.exit(1)
+    sys.exit(0)
+