changeset 11781:6f59154fb604

tests: catch re.error if test line is not a valid regular expression
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Thu, 12 Aug 2010 14:53:34 +0900
parents 3cdd6fdc3d9e
children 992506c14217
files tests/run-tests.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Wed Aug 11 12:30:18 2010 +0200
+++ b/tests/run-tests.py	Thu Aug 12 14:53:34 2010 +0900
@@ -499,6 +499,13 @@
     finally:
         os.remove(name)
 
+    def rematch(el, l):
+        try:
+            return re.match(el, l)
+        except re.error:
+            # el is an invalid regex
+            return False
+
     pos = -1
     postout = []
     for n, l in enumerate(output):
@@ -513,7 +520,7 @@
 
             if el == l: # perfect match (fast)
                 postout.append("  " + l)
-            elif el and re.match(el, l): # fallback regex match
+            elif el and rematch(el, l): # fallback regex match
                 postout.append("  " + el)
             else: # mismatch - let diff deal with it
                 postout.append("  " + l)