# HG changeset patch # User Matt Mackall # Date 1320350925 18000 # Node ID 8c90b3df5bedc6d9d3ad9fcf3ebeff8a230412b0 # Parent 2a62d7c8aee7c2ada2606320cc952ba7bdd17615 run-tests: pull out line matching function diff -r 2a62d7c8aee7 -r 8c90b3df5bed tests/run-tests.py --- 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"