diff options
Diffstat (limited to 'tests-clar/pack/packbuilder.c')
-rw-r--r-- | tests-clar/pack/packbuilder.c | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c index c36b720e2..513778781 100644 --- a/tests-clar/pack/packbuilder.c +++ b/tests-clar/pack/packbuilder.c @@ -9,30 +9,10 @@ static git_packbuilder *_packbuilder; static git_indexer *_indexer; static git_vector _commits; static int _commits_is_initialized; -static char *path_to_cleanup = NULL; -static git_oid oid_to_cleanup = {{0}}; - -static void cleanup_pack(const git_oid *oid) -{ - char *hash, path[1024] = {0}; - - if (git_oid_iszero(&oid_to_cleanup)) return; - - hash = git_oid_allocfmt(oid); - - sprintf(path, "pack-%s.idx", hash); - p_unlink(path); - - sprintf(path, "pack-%s.pack", hash); - p_unlink(path); - - git__free(hash); - git_oid_fromstrn(&oid_to_cleanup, "", 0); -} void test_pack_packbuilder__initialize(void) { - cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git"))); + _repo = cl_git_sandbox_init("testrepo.git"); cl_git_pass(git_revwalk_new(&_revwalker, _repo)); cl_git_pass(git_packbuilder_new(&_packbuilder, _repo)); cl_git_pass(git_vector_init(&_commits, 0, NULL)); @@ -61,14 +41,8 @@ void test_pack_packbuilder__cleanup(void) git_indexer_free(_indexer); _indexer = NULL; - git_repository_free(_repo); + cl_git_sandbox_cleanup(); _repo = NULL; - - if (path_to_cleanup) - cl_fixture_cleanup(path_to_cleanup); - path_to_cleanup = NULL; - - cleanup_pack(&oid_to_cleanup); } static void seed_packbuilder(void) @@ -102,7 +76,6 @@ static void seed_packbuilder(void) void test_pack_packbuilder__create_pack(void) { git_transfer_progress stats; - path_to_cleanup = "testpack.pack"; seed_packbuilder(); cl_git_pass(git_packbuilder_write(_packbuilder, "testpack.pack")); @@ -110,17 +83,13 @@ void test_pack_packbuilder__create_pack(void) cl_git_pass(git_indexer_new(&_indexer, "testpack.pack")); cl_git_pass(git_indexer_run(_indexer, &stats)); cl_git_pass(git_indexer_write(_indexer)); - git_oid_cpy(&oid_to_cleanup, git_indexer_hash(_indexer)); - } static git_transfer_progress stats; static int foreach_cb(void *buf, size_t len, void *payload) { git_indexer_stream *idx = (git_indexer_stream *) payload; - cl_git_pass(git_indexer_stream_add(idx, buf, len, &stats)); - return 0; } @@ -132,6 +101,5 @@ void test_pack_packbuilder__foreach(void) cl_git_pass(git_indexer_stream_new(&idx, ".", NULL, NULL)); cl_git_pass(git_packbuilder_foreach(_packbuilder, foreach_cb, idx)); cl_git_pass(git_indexer_stream_finalize(idx, &stats)); - git_oid_cpy(&oid_to_cleanup, git_indexer_stream_hash(idx)); git_indexer_stream_free(idx); } |