changeset 21444:2b7d364690d8

run-tests: record warnings by raising WarnTest We continue the conversion of recording test results by raising exceptions.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 14:32:03 -0700
parents a6845a042d46
children 092b16448994
files tests/run-tests.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sun Apr 20 14:28:29 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 14:32:03 2014 -0700
@@ -604,6 +604,10 @@
 
                 return '.', self.name, ''
 
+        if self._unittest:
+            if warned:
+                raise WarnTest(msg)
+
         return warned and '~' or '!', self.name, msg
 
     def skip(self, msg):
@@ -991,6 +995,9 @@
 class IgnoreTest(Exception):
     """Raised to indicate that a test is to be ignored."""
 
+class WarnTest(Exception):
+    """Raised to indicate that a test warned."""
+
 class TestResult(unittest._TextTestResult):
     """Holds results when executing via unittest."""
     # Don't worry too much about accessing the non-public _TextTestResult.
@@ -1350,6 +1357,8 @@
                     result.addSkip(self, str(e))
                 except IgnoreTest, e:
                     result.addIgnore(self, str(e))
+                except WarnTest, e:
+                    result.addWarn(self, str(e))
                 except self.failureException:
                     result.addFailure(self, sys.exc_info())
                 except Exception:
@@ -1362,10 +1371,8 @@
 
                 if code == '!':
                     self._result.failures.append((self, msg))
-                elif code == '~':
-                    self._result.addWarn(self, msg)
                 # Codes handled in run().
-                elif code in ('.', 's', 'i'):
+                elif code in ('.', 's', 'i', '~'):
                     pass
                 else:
                     self.fail('Unknown test result code: %s' % code)