run-tests: pull out unified matching funcs stable
authorMatt Mackall <mpm@selenic.com>
Thu, 03 Nov 2011 14:51:04 -0500
branchstable
changeset 1001 21b3c555b6f4
parent 1000 cc9cdab213e1
child 1002 9a8202faebb3
run-tests: pull out unified matching funcs [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Thu Nov 03 14:48:56 2011 -0500
+++ b/tests/run-tests.py	Thu Nov 03 14:51:04 2011 -0500
@@ -521,6 +521,33 @@
 def stringescape(s):
     return escapesub(escapef, s)
 
+def rematch(el, l):
+    try:
+        # ensure that the regex matches to the end of the string
+        return re.match(el + r'\Z', l)
+    except re.error:
+        # 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)
+
 def tsttest(test, wd, options, replacements):
     t = open(test)
     out = []
@@ -608,33 +635,6 @@
     finally:
         os.remove(name)
 
-    def rematch(el, l):
-        try:
-            # ensure that the regex matches to the end of the string
-            return re.match(el + r'\Z', l)
-        except re.error:
-            # 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)
-
     # Merge the script output back into a unified test
 
     pos = -1