Mercurial > hg
comparison tests/run-tests.py @ 12941:b911cb80c671 stable
tests: use (esc) markup for string-escape
This makes test output less ambiguous.
Failing test output will be escaped and marked up if necessary. A Python
string-escape compatible encoding is used, but not everything is encoded -
especially not \n and \t and '.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 08 Nov 2010 01:35:41 +0100 |
parents | 518dd70d1a6e |
children | 158ca54a79cc |
comparison
equal
deleted
inserted
replaced
12940:518dd70d1a6e | 12941:b911cb80c671 |
---|---|
452 def shtest(test, options, replacements): | 452 def shtest(test, options, replacements): |
453 cmd = '"%s"' % test | 453 cmd = '"%s"' % test |
454 vlog("# Running", cmd) | 454 vlog("# Running", cmd) |
455 return run(cmd, options, replacements) | 455 return run(cmd, options, replacements) |
456 | 456 |
457 needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search | |
458 escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub | |
459 escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256)) | |
460 escapemap.update({'\\': '\\\\', '\r': r'\r'}) | |
461 def escapef(m): | |
462 return escapemap[m.group(0)] | |
463 def stringescape(s): | |
464 return escapesub(escapef, s) | |
465 | |
457 def tsttest(test, options, replacements): | 466 def tsttest(test, options, replacements): |
458 t = open(test) | 467 t = open(test) |
459 out = [] | 468 out = [] |
460 script = [] | 469 script = [] |
461 salt = "SALT" + str(time.time()) | 470 salt = "SALT" + str(time.time()) |
543 if pos in expected and expected[pos]: | 552 if pos in expected and expected[pos]: |
544 el = expected[pos].pop(0) | 553 el = expected[pos].pop(0) |
545 | 554 |
546 if el == lout: # perfect match (fast) | 555 if el == lout: # perfect match (fast) |
547 postout.append(" " + lout) | 556 postout.append(" " + lout) |
548 elif el and el.decode('string-escape') == l: | |
549 postout.append(" " + el) # \-escape match | |
550 elif (el and | 557 elif (el and |
551 (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or | 558 (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or |
552 el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout))): | 559 el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout)) or |
553 postout.append(" " + el) # fallback regex/glob match | 560 el.endswith(" (esc)\n") and el.decode('string-escape') == l): |
561 postout.append(" " + el) # fallback regex/glob/esc match | |
554 else: | 562 else: |
563 if needescape(lout): | |
564 lout = stringescape(lout.rstrip('\n')) + " (esc)\n" | |
555 postout.append(" " + lout) # let diff deal with it | 565 postout.append(" " + lout) # let diff deal with it |
556 | 566 |
557 if lcmd: | 567 if lcmd: |
558 # add on last return code | 568 # add on last return code |
559 ret = int(lcmd.split()[1]) | 569 ret = int(lcmd.split()[1]) |