summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2010-01-03 18:52:25 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2010-01-03 18:52:25 +0000
commit5dd6bbd2cfa413497333b482889cbe1b1f413658 (patch)
tree3ce1f410d77d3c983f2c021e02efd258e4dae037
parenta5fc65b46e524725f73a24405b8d2f38afedc3d4 (diff)
Fixed #11615 -- Changed test runners to use an exit status code of 1 for any number of failed tests. The previous behavior of using an exit status code equal to the number of failed tests produced incorrect exit status codes when the number of test failures was 256 or greater. Thanks to lamby for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12068 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/test.py6
-rw-r--r--docs/releases/1.2.txt20
-rwxr-xr-xtests/runtests.py2
3 files changed, 19 insertions, 9 deletions
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 4fd6ba0c8d..46204a7508 100644
--- a/django/core/management/commands/test.py
+++ b/django/core/management/commands/test.py
@@ -17,7 +17,7 @@ class Command(BaseCommand):
def handle(self, *test_labels, **options):
from django.conf import settings
from django.test.utils import get_runner
-
+
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive', True)
failfast = options.get('failfast', False)
@@ -25,10 +25,10 @@ class Command(BaseCommand):
# Some custom test runners won't accept the failfast flag, so let's make sure they accept it before passing it to them
if 'failfast' in test_runner.func_code.co_varnames:
- failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive,
+ failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive,
failfast=failfast)
else:
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
if failures:
- sys.exit(failures)
+ sys.exit(bool(failures))
diff --git a/docs/releases/1.2.txt b/docs/releases/1.2.txt
index 252682a3cf..a549bd0cce 100644
--- a/docs/releases/1.2.txt
+++ b/docs/releases/1.2.txt
@@ -232,6 +232,16 @@ party packages, or that you wrote yourself, you should ensure that the
information, see
:ref:`template tag thread safety considerations<template_tag_thread_safety>`.
+Test runner exit status code
+----------------------------
+
+The exit status code of the test runners (``tests/runtests.py`` and ``python
+manage.py test``) no longer represents the number of failed tests, since a
+failure of 256 or more tests resulted in a wrong exit status code. The exit
+status code for the test runner is now 0 for success (no failing tests) and 1
+for any number of test failures. If needed, the number of test failures can be
+found at the end of the test runner's output.
+
.. _deprecated-features-1.2:
Features deprecated in 1.2
@@ -471,12 +481,12 @@ Models can now use a 64 bit :class:`~django.db.models.BigIntegerField` type.
Fast Failure for Tests
----------------------
-The :djadmin:`test` subcommand of ``django-admin.py``, and the ``runtests.py``
+The :djadmin:`test` subcommand of ``django-admin.py``, and the ``runtests.py``
script used to run Django's own test suite, support a new ``--failfast`` option.
-When specified, this option causes the test runner to exit after encountering
-a failure instead of continuing with the test run. In addition, the handling
-of ``Ctrl-C`` during a test run has been improved to trigger a graceful exit
-from the test run that reports details of the tests run before the interruption.
+When specified, this option causes the test runner to exit after encountering
+a failure instead of continuing with the test run. In addition, the handling
+of ``Ctrl-C`` during a test run has been improved to trigger a graceful exit
+from the test run that reports details of the tests run before the interruption.
Improved localization
---------------------
diff --git a/tests/runtests.py b/tests/runtests.py
index 1cd95b9fef..f2ea5f1271 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -162,7 +162,7 @@ def django_tests(verbosity, interactive, failfast, test_labels):
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, failfast=failfast,
extra_tests=extra_tests)
if failures:
- sys.exit(failures)
+ sys.exit(bool(failures))
# Restore the old settings.
settings.INSTALLED_APPS = old_installed_apps