diff options
author | Ben Straub <bs@github.com> | 2013-01-03 20:38:00 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-01-03 20:38:00 +0400 |
commit | bffbeebbec2878c5329e63b40ecae3715423eac6 (patch) | |
tree | 0e07d160f5dfb99d9c83e528e86edd7ce14bb986 /tests-clar/pack | |
parent | 6fef1ab344326bbdeb45fd653e3c13c233600a35 (diff) |
Cleanup after tests
Diffstat (limited to 'tests-clar/pack')
-rw-r--r-- | tests-clar/pack/packbuilder.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c index b450be6b6..31823eac1 100644 --- a/tests-clar/pack/packbuilder.c +++ b/tests-clar/pack/packbuilder.c @@ -1,6 +1,7 @@ #include "clar_libgit2.h" #include "iterator.h" #include "vector.h" +#include "posix.h" static git_repository *_repo; static git_revwalk *_revwalker; @@ -72,6 +73,21 @@ static void seed_packbuilder(void) } } +static void cleanup_pack(const git_oid *oid) +{ + char *hash, path[1024] = {0}; + + 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); +} + void test_pack_packbuilder__create_pack(void) { git_transfer_progress stats; @@ -82,6 +98,9 @@ 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)); + + cl_fixture_cleanup("testpack.pack"); + cleanup_pack(git_indexer_hash(_indexer)); } static git_transfer_progress stats; @@ -97,10 +116,13 @@ static int foreach_cb(void *buf, size_t len, void *payload) void test_pack_packbuilder__foreach(void) { git_indexer_stream *idx; + git_oid oid; seed_packbuilder(); 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, git_indexer_stream_hash(idx)); git_indexer_stream_free(idx); + cleanup_pack(&oid); } |