Patchwork [3,of,4] run-tests: suggest to append glob when only path sep does not match

login
register
mail settings
Submitter Simon Heimberg
Date Jan. 16, 2014, 11:33 a.m.
Message ID <0b0198d3b9361f4734e2.1389872010@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/3351/
State Superseded
Commit d9d6cbbeef0de78c779ce6e4c624d923b08fb778
Headers show

Comments

Simon Heimberg - Jan. 16, 2014, 11:33 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1389870509 -3600
#      Thu Jan 16 12:08:29 2014 +0100
# Node ID 0b0198d3b9361f4734e24256dd13255b5aec7b44
# Parent  5285c9cfd2632bbebdcb4b9f1a64c647f9046b35
run-tests: suggest to append glob when only path sep does not match

When the line does not match because of \ instead of / (on windows), append
(glob) in the expected output.
This allows to rename test-bla.t.err to test-bla.t for getting a correct
output. This worked for other failures like missing (esc), but not here.

  Output example (only +- lines of diff):
Before:
-  path/with/local/sep
+  path\\with\\local/sep
Now:
-  path/with/local/sep
+  path/with/local/sep (glob)

Patch

diff -r 5285c9cfd263 -r 0b0198d3b936 tests/run-tests.py
--- a/tests/run-tests.py	Thu Jan 16 12:06:49 2014 +0100
+++ b/tests/run-tests.py	Thu Jan 16 12:08:29 2014 +0100
@@ -638,6 +638,8 @@ 
             return rematch(el[:-6], l)
         if el.endswith(" (glob)\n"):
             return globmatch(el[:-8], l)
+        if os.altsep and l.replace('\\', '/') == el:
+            return '+glob'
     return False
 
 def tsttest(test, wd, options, replacements, env):
@@ -791,7 +793,12 @@ 
             if pos in expected and expected[pos]:
                 el = expected[pos].pop(0)
 
-            if linematch(el, lout):
+            r = linematch(el, lout)
+            if isinstance(r, str):
+                if r == '+glob':
+                    lout = el[:-1] + ' (glob)\n'
+                r = False
+            if r:
                 postout.append("  " + el)
             else:
                 if needescape(lout):
diff -r 5285c9cfd263 -r 0b0198d3b936 tests/test-run-tests.py
--- a/tests/test-run-tests.py	Thu Jan 16 12:06:49 2014 +0100
+++ b/tests/test-run-tests.py	Thu Jan 16 12:08:29 2014 +0100
@@ -26,7 +26,10 @@ 
     assert not re.search(r'[^ a-z\\/\r\n()*?]', expected + output), \
            'single backslash or unknown char'
     match = run_tests.linematch(expected, output)
-    return bool(match)
+    if isinstance(match, str):
+        return 'special: ' + match
+    else:
+        return bool(match) # do not return match object
 
 def wintests():
     r"""test matching like running on windows
@@ -47,7 +50,7 @@ 
 
     missing glob
         >>> lm('/g/c/d/fg\n', '\\g\\c\\d/fg\n')
-        False
+        'special: +glob'
 
     restore os.altsep
         >>> os.altsep = _osaltsep