Rev 2672: Add tests which expose our string extraction limitations. in http://bzr.arbash-meinel.com/branches/bzr/0.19-dev/pyrex_knit_extract

John Arbash Meinel john at arbash-meinel.com
Thu Aug 2 22:42:35 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.19-dev/pyrex_knit_extract

------------------------------------------------------------
revno: 2672
revision-id: john at arbash-meinel.com-20070802214201-vhj4072psxshurye
parent: john at arbash-meinel.com-20070727202746-befj022yhetk5i2g
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pyrex_knit_extract
timestamp: Thu 2007-08-02 16:42:01 -0500
message:
  Add tests which expose our string extraction limitations.
modified:
  bzrlib/tests/test__knit_helpers.py test__knit_helpers.p-20070724214127-vkhtjicq8lrlotz3-1
-------------- next part --------------
=== modified file 'bzrlib/tests/test__knit_helpers.py'
--- a/bzrlib/tests/test__knit_helpers.py	2007-07-25 16:50:09 +0000
+++ b/bzrlib/tests/test__knit_helpers.py	2007-08-02 21:42:01 +0000
@@ -128,6 +128,37 @@
         self.assertEqual('abcde12345', digest)
         self.assertEqual(['a foo\n', 'o bar\n'], lines)
 
+    def test_extract_large_fulltext(self):
+        """Extract a fulltext that cannot fit in a fixed-size buffer."""
+        line = ('x'*100000) + '\n' # 100kB per line
+        exp_lines = [line]*20 # 20MB all lines
+        gz_txt = gzip_compress('version rev-id-1 20 12345\n'
+                               + ''.join(exp_lines)
+                               + 'end rev-id-1\n')
+        extract_fulltext = self.get_extract_knit_fulltext_from_gzip()
+        digest, lines = extract_fulltext('rev-id-1', gz_txt, 'test', False)
+        self.assertEqual('12345', digest)
+        if exp_lines != lines:
+            # Don't use assertEqual because we are dealing with a huge output
+            # here, if you need to debug, use pdb
+            self.fail('%s did not extract the expected text'
+                      % (extract_fulltext.__name__,))
+
+    def test_extract_large_single_line_fulltext(self):
+        """Extract a large fulltext that only fits on 1 line."""
+        line = ('x'*10000000) + '\n' # 10MB for one line
+        gz_txt = gzip_compress('version rev-id-1 1 12345\n'
+                               + line
+                               + 'end rev-id-1\n')
+        extract_fulltext = self.get_extract_knit_fulltext_from_gzip()
+        digest, lines = extract_fulltext('rev-id-1', gz_txt, 'test', False)
+        self.assertEqual('12345', digest)
+        if [line] != lines:
+            # Don't use assertEqual because we are dealing with a huge output
+            # here, if you need to debug, use pdb
+            self.fail('%s did not extract the expected text'
+                      % (extract_fulltext.__name__,))
+
 
 class TestExtractKnitFulltextFromGzipCompiled(TestExtractKnitFulltextFromGzip):
     """Test the complied implementation."""



More information about the bazaar-commits mailing list