[PATCH 1 of 2 RESEND] tests: accept \-escaped test output
Yuya Nishihara
yuya at tcha.org
Sat Oct 2 14:42:27 UTC 2010
Oops, I forgot to CC, sorry.
Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1286027845 -32400
> # Node ID fbf65d5f8219ea21d39df0e4933d8ecbbadfb3c8
> # Parent f365aed7cc5b4ce5f42d1e2d20001e2dc7951c5b
> tests: accept \-escaped test output
>
> It changes tsttest to accept expected outputs in python-style \-escapes.
> It aims to avoid trouble with outputs for non-ascii, color and progress
> tests.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -551,6 +551,8 @@ def tsttest(test, options):
>
> if el == l: # perfect match (fast)
> postout.append(" " + l)
> + elif el and el.decode('string-escape') == l:
> + postout.append(" " + el) # \-escape match
It can be the following code if we use escaped test output by default:
if (el is None and l is None) or el.decode('string-escape') == l:
postout.append(" " + el)
# ...
else:
postout.append(" " + l[:-1].encode('string-escape').replace(r"\'", "'")
+ l[-1:]) # let diff deal with it
> elif (el and
> (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
> el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))):
re or glob patterns are not unescaped because they have own escape syntax.
Yuya,
More information about the Mercurial-devel
mailing list