Patchwork [1,of,2] run-tests: factor out _escapepath

login
register
mail settings
Submitter timeless@mozdev.org
Date Feb. 9, 2016, 8:28 p.m.
Message ID <9f2904cf536b2262f9e5.1455049731@waste.org>
Download mbox | patch
Permalink /patch/13074/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - Feb. 9, 2016, 8:28 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1454078134 0
#      Fri Jan 29 14:35:34 2016 +0000
# Node ID 9f2904cf536b2262f9e5b50d9bb6cf35c701f880
# Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
run-tests: factor out _escapepath

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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."""