diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2011-03-31 18:49:22 +0200 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2011-03-31 18:49:22 +0200 |
| commit | 98a19ac1986b623277098263f01696827567c584 (patch) | |
| tree | e1073b86051f45f117cad6575b454f9d415dd565 /gitdb/test | |
| parent | e83210d99aaac5768827c448909fa04d63776e64 (diff) | |
| download | gitdb-98a19ac1986b623277098263f01696827567c584.tar.gz | |
Implemented remainder of the test, and it already shows that something is wrong with my packs. Probably something stupid ;)
Diffstat (limited to 'gitdb/test')
| -rw-r--r-- | gitdb/test/lib.py | 7 | ||||
| -rw-r--r-- | gitdb/test/test_pack.py | 34 |
2 files changed, 29 insertions, 12 deletions
diff --git a/gitdb/test/lib.py b/gitdb/test/lib.py index 342234a..50645be 100644 --- a/gitdb/test/lib.py +++ b/gitdb/test/lib.py @@ -42,19 +42,22 @@ def with_rw_directory(func): def wrapper(self): path = tempfile.mktemp(prefix=func.__name__) os.mkdir(path) + keep = False try: try: return func(self, path) except Exception: print >> sys.stderr, "Test %s.%s failed, output is at %r" % (type(self).__name__, func.__name__, path) + keep = True raise finally: # Need to collect here to be sure all handles have been closed. It appears # a windows-only issue. In fact things should be deleted, as well as # memory maps closed, once objects go out of scope. For some reason # though this is not the case here unless we collect explicitly. - gc.collect() - shutil.rmtree(path) + if not keep: + gc.collect() + shutil.rmtree(path) # END handle exception # END wrapper diff --git a/gitdb/test/test_pack.py b/gitdb/test/test_pack.py index c4d8df1..e9c933e 100644 --- a/gitdb/test/test_pack.py +++ b/gitdb/test/test_pack.py @@ -188,6 +188,10 @@ class TestPack(TestBase): pack_path = tempfile.mktemp('', "pack", rw_dir) index_path = tempfile.mktemp('', 'index', rw_dir) iteration = 0 + def rewind_streams(): + for obj in pack_objs: + obj.stream.seek(0) + #END utility for ppath, ipath, num_obj in zip((pack_path, )*2, (index_path, None), (len(pack_objs), None)): pfile = open(ppath, 'wb') iwrite = None @@ -198,12 +202,11 @@ class TestPack(TestBase): # make sure we rewind the streams ... we work on the same objects over and over again if iteration > 0: - for obj in pack_objs: - obj.stream.seek(0) + rewind_streams() #END rewind streams iteration += 1 - binsha = PackEntity.write_pack(pack_objs, pfile.write, iwrite, object_count=num_obj) + pack_sha, index_sha = PackEntity.write_pack(pack_objs, pfile.write, iwrite, object_count=num_obj) pfile.close() assert os.path.getsize(ppath) > 100 @@ -211,20 +214,31 @@ class TestPack(TestBase): pf = PackFile(ppath) assert pf.size() == len(pack_objs) assert pf.version() == PackFile.pack_version_default - assert pf.checksum() == binsha + assert pf.checksum() == pack_sha # verify index if ipath is not None: + ifile.close() assert os.path.getsize(ipath) > 100 - + idx = PackIndexFile(ipath) + assert idx.version() == PackIndexFile.index_version_default + assert idx.packfile_checksum() == pack_sha + assert idx.indexfile_checksum() == index_sha + assert idx.size() == len(pack_objs) #END verify files exist - - if ifile: - ifile.close() - #END handle index #END for each packpath, indexpath pair - # + # verify the packs throughly + rewind_streams() + entity = PackEntity.create(pack_objs, rw_dir) + count = 0 + for info in entity.info_iter(): + count += 1 + for use_crc in reversed(range(2)): + assert entity.is_valid_stream(info.binsha, use_crc) + # END for each crc mode + #END for each info + assert count == len(pack_objs) def test_pack_64(self): |
