diff options
author | Vicent Marti <tanoku@gmail.com> | 2013-01-03 19:17:07 +0100 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-01-03 19:17:07 +0100 |
commit | 7b51d675e89371661a6c97f76050d4b2477e171a (patch) | |
tree | 89c0167eea789d73f2306bf756c22a4b3b3dc0ae | |
parent | f6fded8f9110aa05fe3d947d9e53cbd5cc13d1d5 (diff) | |
download | libgit2-7b51d675e89371661a6c97f76050d4b2477e171a.tar.gz |
Even more cleanups
-rw-r--r-- | tests-clar/network/fetchlocal.c | 15 | ||||
-rw-r--r-- | tests-clar/odb/alternates.c | 4 | ||||
-rw-r--r-- | tests-clar/pack/packbuilder.c | 36 |
3 files changed, 15 insertions, 40 deletions
diff --git a/tests-clar/network/fetchlocal.c b/tests-clar/network/fetchlocal.c index 9ffbedbfe..ee3bd9db3 100644 --- a/tests-clar/network/fetchlocal.c +++ b/tests-clar/network/fetchlocal.c @@ -11,9 +11,9 @@ static void transfer_cb(const git_transfer_progress *stats, void *payload) (*callcount)++; } -void test_network_fetchlocal__cleanup(void) +static void cleanup_local_repo(void *path) { - cl_fixture_cleanup("foo"); + cl_fixture_cleanup((char *)path); } void test_network_fetchlocal__complete(void) @@ -24,6 +24,8 @@ void test_network_fetchlocal__complete(void) git_strarray refnames = {0}; const char *url = cl_git_fixture_url("testrepo.git"); + + cl_set_cleanup(&cleanup_local_repo, "foo"); cl_git_pass(git_repository_init(&repo, "foo", true)); cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); @@ -40,6 +42,12 @@ void test_network_fetchlocal__complete(void) git_repository_free(repo); } +static void cleanup_sandbox(void *unused) +{ + GIT_UNUSED(unused); + cl_git_sandbox_cleanup(); +} + void test_network_fetchlocal__partial(void) { git_repository *repo = cl_git_sandbox_init("partial-testrepo"); @@ -48,6 +56,7 @@ void test_network_fetchlocal__partial(void) git_strarray refnames = {0}; const char *url; + cl_set_cleanup(&cleanup_sandbox, NULL); cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL)); cl_assert_equal_i(1, (int)refnames.count); @@ -65,6 +74,4 @@ void test_network_fetchlocal__partial(void) git_strarray_free(&refnames); git_remote_free(origin); - - cl_git_sandbox_cleanup(); } diff --git a/tests-clar/odb/alternates.c b/tests-clar/odb/alternates.c index c4b364b16..be7bfa9cd 100644 --- a/tests-clar/odb/alternates.c +++ b/tests-clar/odb/alternates.c @@ -6,7 +6,7 @@ static git_buf destpath, filepath; static const char *paths[] = { "A.git", "B.git", "C.git", "D.git", "E.git", "F.git", "G.git" }; -static git_filebuf file; +static git_filebuf file; static git_repository *repo; void test_odb_alternates__cleanup(void) @@ -16,7 +16,7 @@ void test_odb_alternates__cleanup(void) git_buf_free(&destpath); git_buf_free(&filepath); - for (i=0; i<ARRAY_SIZE(paths); i++) + for (i = 0; i < ARRAY_SIZE(paths); i++) cl_fixture_cleanup(paths[i]); } 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); } |