Commit 7b51d675 by Vicent Marti

Even more cleanups

parent f6fded8f
......@@ -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();
}
......@@ -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]);
}
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment