[PATCH 1 of 2 RFC] tests: asciify test output marked as (escape)

Yuya Nishihara yuya at tcha.org
Wed Sep 29 10:31:19 CDT 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1285773571 -32400
# Node ID 497c8c87e8f0882b4a6bd347888e428390827f7b
# Parent  385fd0eee00524733b7f500a032214b72af78937
tests: asciify test output marked as (escape)

It encodes non-ascii and most control characters of outputs to 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
@@ -532,6 +532,11 @@ def tsttest(test, options):
                 res += re.escape(c)
         return rematch(res, l)
 
+    def escapematch(el, l):
+        # escape everything except for last '\n' character
+        escl = l[:-1].encode('string-escape').replace(r"\'", "'") + l[-1:]
+        return el == escl
+
     pos = -1
     postout = []
     ret = 0
@@ -553,7 +558,9 @@ def tsttest(test, options):
                 postout.append("  " + l)
             elif (el and
                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
-                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))):
+                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
+                   el.endswith(" (escape)\n") and escapematch(el[:-10] + '\n',
+                                                              l))):
                 postout.append("  " + el) # fallback regex/glob match
             else:
                 postout.append("  " + l) # let diff deal with it


More information about the Mercurial-devel mailing list