Mercurial > hg
changeset 15415:8c90b3df5bed
run-tests: pull out line matching function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 03 Nov 2011 15:08:45 -0500 |
parents | 2a62d7c8aee7 |
children | 3b7c4f96885c |
files | tests/run-tests.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Thu Nov 03 14:51:04 2011 -0500 +++ b/tests/run-tests.py Thu Nov 03 15:08:45 2011 -0500 @@ -548,6 +548,16 @@ res += re.escape(c) return rematch(res, l) +def linematch(el, l): + if el == l: # perfect match (fast) + return True + if (el and + (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or + el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or + el.endswith(" (esc)\n") and el.decode('string-escape') == l)): + return True + return False + def tsttest(test, wd, options, replacements): t = open(test) out = [] @@ -655,14 +665,8 @@ if pos in expected and expected[pos]: el = expected[pos].pop(0) - if el == lout: # perfect match (fast) - postout.append(" " + lout) - elif (el and - (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or - el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout) - or el.endswith(" (esc)\n") and - el.decode('string-escape') == l)): - postout.append(" " + el) # fallback regex/glob/esc match + if linematch(el, lout): + postout.append(" " + el) else: if needescape(lout): lout = stringescape(lout.rstrip('\n')) + " (esc)\n"