]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse/runtests: truncate expected file contents in reported error message
authorrobk-tahoe <robk-tahoe@allmydata.com>
Mon, 20 Oct 2008 14:45:23 +0000 (07:45 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Mon, 20 Oct 2008 14:45:23 +0000 (07:45 -0700)
this avoids dumping the repr of 1Mb of random data to stdout in the event
of a test failure, but rather just dumps the start/end of the errant strings
if the amount of data is > 200 chars repr'd

contrib/fuse/runtests.py

index 756b83663ea570f68012029ea94b457aa3e70988..9f03bd8b928443ef33f158df6bc8e42c0d0ddc0e 100644 (file)
@@ -491,9 +491,15 @@ class SystemTest (object):
 
     def _check_write(self, testcap, name, expected_body):
         uploaded_body = self.get_file(testcap, name)
+        def drepr(obj):
+            r = repr(obj)
+            if len(r) > 200:
+                return r[:100] + ' ... ' + r[-100:]
+            else:
+                return r
         if uploaded_body != expected_body:
-            tmpl = 'Expected file contents %r but found %r'
-            raise TestFailure(tmpl, expected_body, uploaded_body)
+            tmpl = 'Expected file contents %s but found %s'
+            raise TestFailure(tmpl, drepr(expected_body), drepr(uploaded_body))
 
     def test_write_overlapping_small_writes(self, testcap, testdir):
         self._write_test_overlap(testcap, testdir, name='large_overlap', bs=2**9, sz=2**20)