[Pkg-bazaar-commits] ./bzr/unstable r863: - more hashcache tests
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:13:40 UTC 2009
------------------------------------------------------------
revno: 863
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-07-08 12:49:15 +1000
message:
- more hashcache tests
modified:
bzrlib/selftest/testhashcache.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/testhashcache.py'
--- a/bzrlib/selftest/testhashcache.py 2005-07-08 02:40:22 +0000
+++ b/bzrlib/selftest/testhashcache.py 2005-07-08 02:49:15 +0000
@@ -75,20 +75,27 @@
file('foo', 'wb').write('g00dbye')
self.assertEquals(hc.get_sha1('foo'),
sha1('g00dbye'))
-
- # this is not quite guaranteed to be true; we might have
- # crossed a 1s boundary before
- self.assertEquals(hc.danger_count, 1)
- self.assertEquals(len(hc._cache), 0)
+
+ file('foo2', 'wb').write('other file')
+ self.assertEquals(hc.get_sha1('foo2'), sha1('other file'))
+
+ os.remove('foo2')
+ self.assertEquals(hc.get_sha1('foo2'), None)
+
+ file('foo2', 'wb').write('new content')
+ self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
self.assertEquals(hc.get_sha1('subdir'), None)
+ # it's likely neither are cached at the moment because they
+ # changed recently, but we can't be sure
pause()
- # should now be safe to cache it
- self.assertEquals(hc.get_sha1('foo'),
- sha1('g00dbye'))
+ # should now be safe to cache it if we reread them
+ self.assertEquals(hc.get_sha1('foo'), sha1('g00dbye'))
self.assertEquals(len(hc._cache), 1)
+ self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
+ self.assertEquals(len(hc._cache), 2)
# write out, read back in and check that we don't need to
# re-read any files
@@ -98,10 +105,12 @@
hc = HashCache('.')
hc.read('stat-cache')
- self.assertEquals(len(hc._cache), 1)
+ self.assertEquals(len(hc._cache), 2)
self.assertEquals(hc.get_sha1('foo'), sha1('g00dbye'))
self.assertEquals(hc.hit_count, 1)
self.assertEquals(hc.miss_count, 0)
+ self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
+
More information about the Pkg-bazaar-commits
mailing list