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

login
register
mail settings
Submitter Gregory Szorc
Date May 28, 2014, 2:21 a.m.
Message ID <e5fa751068fd637301a4.1401243692@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4874/
State Accepted
Commit b3213b9fafed0a7363945248ca10a4e55a244fe8
Headers show

Comments

Gregory Szorc - May 28, 2014, 2:21 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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: