D3881: tests: don't allow reodering of glob/re lines across non-glob/re lines

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jul 5 08:10:58 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf83600efa1ca: tests: don't allow reodering of glob/re lines across non-glob/re lines (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3881?vs=9428&id=9452

REVISION DETAIL
  https://phab.mercurial-scm.org/D3881

AFFECTED FILES
  tests/run-tests.py
  tests/test-run-tests.py
  tests/test-run-tests.t

CHANGE DETAILS

diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -142,21 +142,18 @@
   
   --- $TESTTMP/test-failure-globs.t
   +++ $TESTTMP/test-failure-globs.t.err
-  @@ -2,10 +2,10 @@
+  @@ -2,9 +2,9 @@
      context
      context
      key: 1
   -  value: a
-  +  value: * (glob)
+  +  value: not a
      key: 2
   -  value: b
-  +  value: * (glob)
+  +  value: not b
      key: 3
-  -  value: * (glob)
-  +  value: c
+     value: * (glob)
      key: 4
-  -  value: * (glob)
-  +  value: d
   
   ERROR: test-failure-globs.t output changed
   !
diff --git a/tests/test-run-tests.py b/tests/test-run-tests.py
--- a/tests/test-run-tests.py
+++ b/tests/test-run-tests.py
@@ -40,7 +40,7 @@
     assert not re.search(br'[^ \w\\/\r\n()*?]', expected + output), \
            b'single backslash or unknown char'
     test = run_tests.TTest(b'test-run-test.t', b'.', b'.')
-    match = test.linematch(expected, output)
+    match, exact = test.linematch(expected, output)
     if isinstance(match, str):
         return 'special: ' + match
     elif isinstance(match, bytes):
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1484,7 +1484,7 @@
                 for i, el in enumerate(els):
                     r = False
                     if el:
-                        r = self.linematch(el, lout)
+                        r, exact = self.linematch(el, lout)
                     if isinstance(r, str):
                         if r == '-glob':
                             lout = ''.join(el.rsplit(' (glob)', 1))
@@ -1508,6 +1508,11 @@
 
                                 if not self._iftest(conditions):
                                     optional.append(i)
+                        if exact:
+                            # Don't allow line to be matches against a later
+                            # line in the output
+                            els.pop(i)
+                            break
 
                 if r:
                     if r == "retry":
@@ -1608,7 +1613,7 @@
 
     def linematch(self, el, l):
         if el == l: # perfect match (fast)
-            return True
+            return True, True
         retry = False
         if el.endswith(b" (?)\n"):
             retry = "retry"
@@ -1629,19 +1634,19 @@
             else:
                 el = el[:-7].decode('string-escape') + '\n'
         if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l:
-            return True
+            return True, True
         if el.endswith(b" (re)\n"):
-            return TTest.rematch(el[:-6], l) or retry
+            return (TTest.rematch(el[:-6], l) or retry), False
         if el.endswith(b" (glob)\n"):
             # ignore '(glob)' added to l by 'replacements'
             if l.endswith(b" (glob)\n"):
                 l = l[:-8] + b"\n"
-            return TTest.globmatch(el[:-8], l) or retry
+            return (TTest.globmatch(el[:-8], l) or retry), False
         if os.altsep:
             _l = l.replace(b'\\', b'/')
             if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l:
-                return True
-        return retry
+                return True, True
+        return retry, True
 
     @staticmethod
     def parsehghaveoutput(lines):



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list