[PATCH 1 of 2] run-tests: exit with non-0 exit code when tests fail or warn

Gregory Szorc gregory.szorc at gmail.com
Wed May 28 02:21:32 UTC 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1401243022 25200
#      Tue May 27 19:10:22 2014 -0700
# Node ID e5fa751068fd637301a48a43f642e2d8abb31fa4
# Parent  652e07debf10193f4973a48ead96a95e81d0a55b
run-tests: exit with non-0 exit code when tests fail or warn

As part of the run-tests.py refactor, run-tests.py accidentally started
exiting with 0 for most test runs. This patch restores the expected
behavior.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1317,8 +1317,10 @@ class TextTestRunner(unittest.TextTestRu
                 os.environ['PYTHONHASHSEED'])
         if self._runner.options.time:
             self.printtimes(result.times)
 
+        return result
+
     def printtimes(self, times):
         self.stream.writeln('# Producing time report')
         times.sort(key=lambda t: (t[1], t[0]), reverse=True)
         cols = '%7.3f   %s'
@@ -1536,9 +1538,14 @@ class TestRunner(object):
             verbosity = 1
             if self.options.verbose:
                 verbosity = 2
             runner = TextTestRunner(self, verbosity=verbosity)
-            runner.run(suite)
+            result = runner.run(suite)
+
+            if result.failures:
+                failed = True
+            if result.warned:
+                warned = True
 
             if self.options.anycoverage:
                 self._outputcoverage()
         except KeyboardInterrupt:


More information about the Mercurial-devel mailing list