Patchwork test-pathencode: actually compare our current pathencoding implemenentations

login
register
mail settings
Submitter Adrian Buehlmann
Date Dec. 15, 2012, 9:48 a.m.
Message ID <881d00d006a15e6d6d04.1355564926@kork>
Download mbox | patch
Permalink /patch/118/
State Superseded
Headers show

Comments

Adrian Buehlmann - Dec. 15, 2012, 9:48 a.m.
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1355564827 -3600
# Node ID 881d00d006a15e6d6d0494d8d58a14e7e178d4c3
# Parent  6f62e005781dd6e410b4a9f47ec96c583d59a792
test-pathencode: actually compare our current pathencoding implemenentations

Patch

diff --git a/tests/test-pathencode.py b/tests/test-pathencode.py
--- a/tests/test-pathencode.py
+++ b/tests/test-pathencode.py
@@ -13,9 +13,6 @@ 
 if sys.version_info[:2] < (2, 6):
     sys.exit(0)
 
-def hybridencode(path):
-    return store._hybridencode(path, True)
-
 validchars = set(map(chr, range(0, 256)))
 alphanum = range(ord('A'), ord('Z'))
 
@@ -157,7 +154,15 @@ 
 def runtests(rng, seed, count):
     nerrs = 0
     for p in genpath(rng, count):
-        hybridencode(p)
+        h = store._dothybridencode(p)    # uses C implementation, if available
+        r = store._hybridencode(p, True) # reference implementation in Python
+        if h != r:
+            if nerrs == 0:
+                print >> sys.stderr, 'seed:', hex(seed)[:-1]
+            print >> sys.stderr, "\np: '%s'" % p.encode("string_escape")
+            print >> sys.stderr, "h: '%s'" % h.encode("string_escape")
+            print >> sys.stderr, "r: '%s'" % r.encode("string_escape")
+            nerrs += 1
     return nerrs
 
 def main():