Rev 2508: Add direct tests of how we handle incomplete/'broken' lines in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
John Arbash Meinel
john at arbash-meinel.com
Thu Jul 5 20:39:57 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
------------------------------------------------------------
revno: 2508
revision-id: john at arbash-meinel.com-20070705193928-xtm8nh4ucc8qosdn
parent: john at arbash-meinel.com-20070702183631-ylkveb8ux8imm6cx
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: knit_index_pyrex
timestamp: Thu 2007-07-05 14:39:28 -0500
message:
Add direct tests of how we handle incomplete/'broken' lines
modified:
bzrlib/_knit_load_data_c.pyx knit_c.pyx-20070509143944-u42gy8w387a10m0j-1
bzrlib/_knit_load_data_py.py _knit_load_data_py.p-20070629000948-9a0nh4s118bi5y8n-1
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
-------------- next part --------------
=== modified file 'bzrlib/_knit_load_data_c.pyx'
--- a/bzrlib/_knit_load_data_c.pyx 2007-06-29 17:14:16 +0000
+++ b/bzrlib/_knit_load_data_c.pyx 2007-07-05 19:39:28 +0000
@@ -260,15 +260,11 @@
# Process until the end of the file
last = self.end_str - 1
self.cur_str = self.end_str
- line = PyString_FromStringAndSize(start, last - start)
- ending = PyString_FromStringAndSize(last, 1)
else:
# The last character is right before the '\n'
# And the next string is right after it
- line = PyString_FromStringAndSize(start, last - start)
self.cur_str = last + 1
last = last - 1
- ending = PyString_FromStringAndSize(last, 3)
if last <= start or last[0] != c':':
# Incomplete record
=== modified file 'bzrlib/_knit_load_data_py.py'
--- a/bzrlib/_knit_load_data_py.py 2007-06-29 16:00:06 +0000
+++ b/bzrlib/_knit_load_data_py.py 2007-07-05 19:39:28 +0000
@@ -38,7 +38,7 @@
if len(rec) < 5 or rec[-1] != ':':
# corrupt line.
# FIXME: in the future we should determine if its a
- # short write - and ignore it
+ # short write - and ignore it
# or a different failure, and raise. RBC 20060407
continue
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-07-02 18:36:31 +0000
+++ b/bzrlib/tests/test_knit.py 2007-07-05 19:39:28 +0000
@@ -795,6 +795,37 @@
else:
raise
+ def test_short_line(self):
+ transport = MockTransport([
+ _KnitIndex.HEADER,
+ "a option 0 10 :",
+ "b option 10 10 0", # This line isn't terminated, ignored
+ ])
+ index = self.get_knit_index(transport, "filename", "r")
+ self.assertEqual(['a'], index.get_versions())
+
+ def test_skip_incomplete_record(self):
+ # A line with bogus data should just be skipped
+ transport = MockTransport([
+ _KnitIndex.HEADER,
+ "a option 0 10 :",
+ "b option 10 10 0", # This line isn't terminated, ignored
+ "c option 20 10 0 :", # Properly terminated, and starts with '\n'
+ ])
+ index = self.get_knit_index(transport, "filename", "r")
+ self.assertEqual(['a', 'c'], index.get_versions())
+
+ def test_trailing_characters(self):
+ # A line with bogus data should just be skipped
+ transport = MockTransport([
+ _KnitIndex.HEADER,
+ "a option 0 10 :",
+ "b option 10 10 0 :a", # This line has extra trailing characters
+ "c option 20 10 0 :", # Properly terminated, and starts with '\n'
+ ])
+ index = self.get_knit_index(transport, "filename", "r")
+ self.assertEqual(['a', 'c'], index.get_versions())
+
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
More information about the bazaar-commits
mailing list