Mercurial > hg > mercurial-source
changeset 12938: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 | 05fffd665170 |
files | tests/run-tests.py tests/test-encoding-align.t tests/test-patchbomb.t |
diffstat | 3 files changed, 27 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -454,6 +454,15 @@ vlog("# Running", cmd) return run(cmd, options, replacements) +needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search +escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub +escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256)) +escapemap.update({'\\': '\\\\', '\r': r'\r'}) +def escapef(m): + return escapemap[m.group(0)] +def stringescape(s): + return escapesub(escapef, s) + def tsttest(test, options, replacements): t = open(test) out = [] @@ -545,13 +554,14 @@ if el == lout: # perfect match (fast) postout.append(" " + lout) - elif el and el.decode('string-escape') == l: - postout.append(" " + el) # \-escape match elif (el and (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or - el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout))): - postout.append(" " + el) # fallback regex/glob match + 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 else: + if needescape(lout): + lout = stringescape(lout.rstrip('\n')) + " (esc)\n" postout.append(" " + lout) # let diff deal with it if lcmd:
--- a/tests/test-encoding-align.t +++ b/tests/test-encoding-align.t @@ -52,9 +52,9 @@ options: - -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width + -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width (esc) -m --opt2 MIDDLE_ middle width - -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width + -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width (esc) use "hg -v help showoptlist" to show global options @@ -96,42 +96,42 @@ check alignment of user names in annotate $ hg annotate -u $M - \xe7\x9f\xad\xe5\x90\x8d: first line(2) + \xe7\x9f\xad\xe5\x90\x8d: first line(2) (esc) MIDDLE_: second line(2) - \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) + \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) (esc) check alignment of filenames in diffstat $ hg diff -c tip --stat MIDDLE_ | 1 + - \xe7\x9f\xad\xe5\x90\x8d | 1 + - \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d | 1 + + \xe7\x9f\xad\xe5\x90\x8d | 1 + (esc) + \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d | 1 + (esc) 3 files changed, 3 insertions(+), 0 deletions(-) add branches/tags $ hg branch $S - marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d + marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc) $ hg tag $S $ hg branch $M marked working directory as branch MIDDLE_ $ hg tag $M $ hg branch $L - marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d + marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) $ hg tag $L check alignment of branches $ hg tags tip 5:d745ff46155b - \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 + \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 (esc) MIDDLE_ 3:b06c5b6def9e - \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 + \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 (esc) check alignment of tags $ hg tags tip 5:d745ff46155b - \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 + \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 (esc) MIDDLE_ 3:b06c5b6def9e - \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 + \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 (esc)
--- a/tests/test-patchbomb.t +++ b/tests/test-patchbomb.t @@ -148,7 +148,7 @@ $ hg email -m test.mbox -f quux -t foo -c bar -s test 0:tip \ > --config extensions.progress= --config progress.assume-tty=1 \ > --config progress.delay=0 --config progress.refresh=0 - \rwriting [ ] 0/3\rwriting [ ] 0/3\r \r\r \r\rwriting [====================> ] 1/3\rwriting [====================> ] 1/3\r \r\r \r\rwriting [==========================================> ] 2/3\rwriting [==========================================> ] 2/3\r \rThis patch series consists of 2 patches. + \rwriting [ ] 0/3\rwriting [ ] 0/3\r \r\r \r\rwriting [====================> ] 1/3\rwriting [====================> ] 1/3\r \r\r \r\rwriting [==========================================> ] 2/3\rwriting [==========================================> ] 2/3\r \rThis patch series consists of 2 patches. (esc) Write the introductory message for the patch series.