Rev 2673: Add more (failing) tests for line deltas in the same way as fulltexts 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:55:38 BST 2007


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

------------------------------------------------------------
revno: 2673
revision-id: john at arbash-meinel.com-20070802215505-hahicpf9014hhe3o
parent: john at arbash-meinel.com-20070802214201-vhj4072psxshurye
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pyrex_knit_extract
timestamp: Thu 2007-08-02 16:55:05 -0500
message:
  Add more (failing) tests for line deltas in the same way as fulltexts
modified:
  bzrlib/_knit_helpers_c.pyx     knit_c.pyx-20070509143944-u42gy8w387a10m0j-1
  bzrlib/tests/test__knit_helpers.py test__knit_helpers.p-20070724214127-vkhtjicq8lrlotz3-1
-------------- next part --------------
=== modified file 'bzrlib/_knit_helpers_c.pyx'
--- a/bzrlib/_knit_helpers_c.pyx	2007-07-27 20:27:46 +0000
+++ b/bzrlib/_knit_helpers_c.pyx	2007-08-02 21:55:05 +0000
@@ -563,6 +563,8 @@
 
         :postcondition: self.cur_line and self.cur_line_size will be updated
             to point to the next line to be processed.
+        :return: 1 to indicate we have a valid line
+                 0 to indicate we are at EOF
         """
         # This currently uses a buffering scheme for extracting text
         # When we come into this function, if we have some decompressed data,

=== modified file 'bzrlib/tests/test__knit_helpers.py'
--- a/bzrlib/tests/test__knit_helpers.py	2007-08-02 21:42:01 +0000
+++ b/bzrlib/tests/test__knit_helpers.py	2007-08-02 21:55:05 +0000
@@ -204,6 +204,62 @@
         self.assertEqual('abcde12345', digest)
         self.assertEqual([(0, 1, 2, ['a foo\n', 'o bar\n'])], deltas)
 
+    def test_extract_multiple_deltas(self):
+        gz_txt = gzip_compress('version rev-id-1 5 abcde12345\n'
+                               '0,1,2\n'
+                               'rev-id-x a foo\n'
+                               'rev-id-y o bar\n'
+                               '8,10,1\n'
+                               'rev-id-z no zing\n'
+                               'end rev-id-1\n')
+        extract_linedelta = self.get_extract_knit_linedelta_from_gzip()
+        digest, deltas = extract_linedelta('rev-id-1', gz_txt, 'test', True)
+        self.assertEqual('abcde12345', digest)
+        self.assertEqual([(0, 1, 2, ['a foo\n', 'o bar\n']),
+                          (8, 10, 1, ['no zing\n']),
+                         ], deltas)
+        extract_linedelta = self.get_extract_knit_linedelta_from_gzip()
+        digest, deltas = extract_linedelta('rev-id-1', gz_txt, 'test', False)
+        self.assertEqual('abcde12345', digest)
+        self.assertEqual([(0, 1, 2, ['rev-id-x a foo\n', 'rev-id-y o bar\n']),
+                          (8, 10, 1, ['rev-id-z no zing\n']),
+                         ], deltas)
+
+    def test_extract_large_linedelta(self):
+        """Extract a linedelta 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 21 12345\n'
+                               '0,1,20\n'
+                               + ''.join(exp_lines)
+                               + 'end rev-id-1\n')
+        extract_linedelta = self.get_extract_knit_linedelta_from_gzip()
+        digest, deltas = extract_linedelta('rev-id-1', gz_txt, 'test', False)
+        self.assertEqual('12345', digest)
+        exp_deltas = [(0, 1, 20, exp_lines)]
+        if exp_deltas != deltas:
+            # 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 delta'
+                      % (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 2 12345\n'
+                               '3,4,1\n'
+                               + line
+                               + 'end rev-id-1\n')
+        extract_linedelta = self.get_extract_knit_linedelta_from_gzip()
+        digest, deltas = extract_linedelta('rev-id-1', gz_txt, 'test', False)
+        self.assertEqual('12345', digest)
+        exp_deltas = [(3, 4, 1, [line])]
+        if exp_deltas != deltas:
+            # 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 delta'
+                      % (extract_fulltext.__name__,))
+
 
 class TestExtractKnitLineDeltaFromGzipCompiled(TestExtractKnitLinedeltaFromGzip):
     """Test the complied implementation."""



More information about the bazaar-commits mailing list