Mercurial > hg
changeset 21316:ab9bf8a5e573
run-tests: make rematch a static method of TTest
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 16:13:02 -0700 |
parents | 56610da39b48 |
children | 58a599784a0c |
files | tests/run-tests.py |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Apr 19 16:11:49 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 16:13:02 2014 -0700 @@ -695,16 +695,6 @@ def stringescape(s): return escapesub(escapef, s) -def rematch(el, l): - try: - # use \Z to ensure that the regex matches to the end of the string - if os.name == 'nt': - return re.match(el + r'\r?\n\Z', l) - return re.match(el + r'\n\Z', l) - except re.error: - # el is an invalid regex - return False - def globmatch(el, l): # The only supported special characters are * and ? plus / which also # matches \ on windows. Escaping of these characters is supported. @@ -729,7 +719,7 @@ res += '[/\\\\]' else: res += re.escape(c) - return rematch(res, l) + return TTest.rematch(res, l) class TTest(Test): """A "t test" is a test backed by a .t file.""" @@ -944,6 +934,17 @@ return exitcode, postout @staticmethod + def rematch(el, l): + try: + # use \Z to ensure that the regex matches to the end of the string + if os.name == 'nt': + return re.match(el + r'\r?\n\Z', l) + return re.match(el + r'\n\Z', l) + except re.error: + # el is an invalid regex + return False + + @staticmethod def linematch(el, l): if el == l: # perfect match (fast) return True @@ -953,7 +954,7 @@ if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: return True if el.endswith(" (re)\n"): - return rematch(el[:-6], l) + return TTest.rematch(el[:-6], l) if el.endswith(" (glob)\n"): return globmatch(el[:-8], l) if os.altsep and l.replace('\\', '/') == el: