run-tests: factor out _escapepath
authortimeless <timeless@mozdev.org>
Fri, 29 Jan 2016 14:35:34 +0000
changeset 28055 92e8e3f20a6f
parent 28054 8515b813976b
child 28058 ff6e8dc659f8
run-tests: factor out _escapepath
tests/run-tests.py
--- a/tests/run-tests.py	Mon Feb 08 12:33:00 2016 -0500
+++ b/tests/run-tests.py	Fri Jan 29 14:35:34 2016 +0000
@@ -724,16 +724,19 @@
             (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$',
              br'\1 (glob)'),
             ]
+        r.append((self._escapepath(self._testtmp), b'$TESTTMP'))
 
+        return r
+
+    def _escapepath(self, p):
         if os.name == 'nt':
-            r.append(
+            return (
                 (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or
                     c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c
-                    for c in self._testtmp), b'$TESTTMP'))
+                    for c in p))
+            )
         else:
-            r.append((re.escape(self._testtmp), b'$TESTTMP'))
-
-        return r
+            return re.escape(p)
 
     def _getenv(self):
         """Obtain environment variables to use during test execution."""