Mercurial > hg
comparison tests/run-tests.py @ 38552:5a20b6090a6e
tests: move handling of None "el" out of linematch()
It just seems odd for linematch() to know what None means.
Differential Revision: https://phab.mercurial-scm.org/D3879
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 03 Jul 2018 15:30:22 -0700 |
parents | 174484b2528d |
children | f83600efa1ca |
comparison
equal
deleted
inserted
replaced
38551:174484b2528d | 38552:5a20b6090a6e |
---|---|
1480 if expected.get(pos, None): | 1480 if expected.get(pos, None): |
1481 els = expected[pos] | 1481 els = expected[pos] |
1482 | 1482 |
1483 optional = [] | 1483 optional = [] |
1484 for i, el in enumerate(els): | 1484 for i, el in enumerate(els): |
1485 | 1485 r = False |
1486 r = self.linematch(el, lout) | 1486 if el: |
1487 r = self.linematch(el, lout) | |
1487 if isinstance(r, str): | 1488 if isinstance(r, str): |
1488 if r == '-glob': | 1489 if r == '-glob': |
1489 lout = ''.join(el.rsplit(' (glob)', 1)) | 1490 lout = ''.join(el.rsplit(' (glob)', 1)) |
1490 r = '' # Warn only this line. | 1491 r = '' # Warn only this line. |
1491 elif r == "retry": | 1492 elif r == "retry": |
1604 else: | 1605 else: |
1605 res += re.escape(c) | 1606 res += re.escape(c) |
1606 return TTest.rematch(res, l) | 1607 return TTest.rematch(res, l) |
1607 | 1608 |
1608 def linematch(self, el, l): | 1609 def linematch(self, el, l): |
1609 retry = False | |
1610 if el == l: # perfect match (fast) | 1610 if el == l: # perfect match (fast) |
1611 return True | 1611 return True |
1612 if el: | 1612 retry = False |
1613 if el.endswith(b" (?)\n"): | 1613 if el.endswith(b" (?)\n"): |
1614 retry = "retry" | 1614 retry = "retry" |
1615 el = el[:-5] + b"\n" | 1615 el = el[:-5] + b"\n" |
1616 else: | |
1617 m = optline.match(el) | |
1618 if m: | |
1619 conditions = [c for c in m.group(2).split(b' ')] | |
1620 | |
1621 el = m.group(1) + b"\n" | |
1622 if not self._iftest(conditions): | |
1623 retry = "retry" # Not required by listed features | |
1624 | |
1625 if el.endswith(b" (esc)\n"): | |
1626 if PYTHON3: | |
1627 el = el[:-7].decode('unicode_escape') + '\n' | |
1628 el = el.encode('utf-8') | |
1616 else: | 1629 else: |
1617 m = optline.match(el) | 1630 el = el[:-7].decode('string-escape') + '\n' |
1618 if m: | 1631 if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l: |
1619 conditions = [c for c in m.group(2).split(b' ')] | 1632 return True |
1620 | 1633 if el.endswith(b" (re)\n"): |
1621 el = m.group(1) + b"\n" | 1634 return TTest.rematch(el[:-6], l) or retry |
1622 if not self._iftest(conditions): | 1635 if el.endswith(b" (glob)\n"): |
1623 retry = "retry" # Not required by listed features | 1636 # ignore '(glob)' added to l by 'replacements' |
1624 | 1637 if l.endswith(b" (glob)\n"): |
1625 if el.endswith(b" (esc)\n"): | 1638 l = l[:-8] + b"\n" |
1626 if PYTHON3: | 1639 return TTest.globmatch(el[:-8], l) or retry |
1627 el = el[:-7].decode('unicode_escape') + '\n' | 1640 if os.altsep: |
1628 el = el.encode('utf-8') | 1641 _l = l.replace(b'\\', b'/') |
1629 else: | 1642 if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l: |
1630 el = el[:-7].decode('string-escape') + '\n' | |
1631 if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l: | |
1632 return True | 1643 return True |
1633 if el.endswith(b" (re)\n"): | |
1634 return TTest.rematch(el[:-6], l) or retry | |
1635 if el.endswith(b" (glob)\n"): | |
1636 # ignore '(glob)' added to l by 'replacements' | |
1637 if l.endswith(b" (glob)\n"): | |
1638 l = l[:-8] + b"\n" | |
1639 return TTest.globmatch(el[:-8], l) or retry | |
1640 if os.altsep: | |
1641 _l = l.replace(b'\\', b'/') | |
1642 if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l: | |
1643 return True | |
1644 return retry | 1644 return retry |
1645 | 1645 |
1646 @staticmethod | 1646 @staticmethod |
1647 def parsehghaveoutput(lines): | 1647 def parsehghaveoutput(lines): |
1648 '''Parse hghave log lines. | 1648 '''Parse hghave log lines. |