Mercurial > hg
comparison tests/run-tests.py @ 11781:6f59154fb604
tests: catch re.error if test line is not a valid regular expression
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Thu, 12 Aug 2010 14:53:34 +0900 |
parents | 431e2bf37ae7 |
children | 4134686b83e1 |
comparison
equal
deleted
inserted
replaced
11780:3cdd6fdc3d9e | 11781:6f59154fb604 |
---|---|
497 vlog("# Running", cmd) | 497 vlog("# Running", cmd) |
498 exitcode, output = run(cmd, options) | 498 exitcode, output = run(cmd, options) |
499 finally: | 499 finally: |
500 os.remove(name) | 500 os.remove(name) |
501 | 501 |
502 def rematch(el, l): | |
503 try: | |
504 return re.match(el, l) | |
505 except re.error: | |
506 # el is an invalid regex | |
507 return False | |
508 | |
502 pos = -1 | 509 pos = -1 |
503 postout = [] | 510 postout = [] |
504 for n, l in enumerate(output): | 511 for n, l in enumerate(output): |
505 if l.startswith(salt): | 512 if l.startswith(salt): |
506 if pos in after: | 513 if pos in after: |
511 if pos in expected and expected[pos]: | 518 if pos in expected and expected[pos]: |
512 el = expected[pos].pop(0) | 519 el = expected[pos].pop(0) |
513 | 520 |
514 if el == l: # perfect match (fast) | 521 if el == l: # perfect match (fast) |
515 postout.append(" " + l) | 522 postout.append(" " + l) |
516 elif el and re.match(el, l): # fallback regex match | 523 elif el and rematch(el, l): # fallback regex match |
517 postout.append(" " + el) | 524 postout.append(" " + el) |
518 else: # mismatch - let diff deal with it | 525 else: # mismatch - let diff deal with it |
519 postout.append(" " + l) | 526 postout.append(" " + l) |
520 | 527 |
521 if pos in after: | 528 if pos in after: |