D3881: tests: don't allow reodering of glob/re lines across non-glob/re lines
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue Jul 3 23:43:25 UTC 2018
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
As shown in the test case added in the previous patch, it can be
really hard to interpret diffs from the test runner if there are
multiple lines that would match a given glob or regular expression. It
looks like this has been the case since https://phab.mercurial-scm.org/rHG1ad0ddf8cccca4c6285598499fbb31de49ddb8ca (run-tests: teach
_processoutput to handle multiple lines of churn, 2016-03-17). It
seems like the point of that was to preserve the "(glob)" annotation
on lines even if they got moved. This patch tries to preserve that but
only allows the lines to be moved past other glob/re lines.
REPOSITORY
rHG Mercurial
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