tests/run-tests.py
branchstable
changeset 801 413c6fe6d1e3
parent 800 c4211177a2fc
child 802 630d72ae4f76
--- a/tests/run-tests.py	Wed Sep 22 16:06:00 2010 -0500
+++ b/tests/run-tests.py	Wed Sep 22 16:06:02 2010 -0500
@@ -509,6 +509,25 @@
             # el is an invalid regex
             return False
 
+    def globmatch(el, l):
+        # The only supported special characters are * and ?. Escaping is
+        # supported.
+        i, n = 0, len(el)
+        res = ''
+        while i < n:
+            c = el[i]
+            i += 1
+            if c == '\\' and el[i] in '*?\\':
+                res += el[i-1:i+1]
+                i += 1
+            elif c == '*':
+                res += '.*'
+            elif c == '?':
+                res += '.'
+            else:
+                res += re.escape(c)
+        return rematch(res, l)
+
     pos = -1
     postout = []
     ret = 0
@@ -528,8 +547,10 @@
 
             if el == l: # perfect match (fast)
                 postout.append("  " + l)
-            elif el and el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l):
-                postout.append("  " + el) # fallback regex match
+            elif (el and
+                  (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
+                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))):
+                postout.append("  " + el) # fallback regex/glob match
             else:
                 postout.append("  " + l) # let diff deal with it