Commit bffbeebb by Ben Straub

Cleanup after tests

parent 6fef1ab3
...@@ -441,6 +441,7 @@ void test_config_read__can_load_and_parse_an_empty_config_file(void) ...@@ -441,6 +441,7 @@ void test_config_read__can_load_and_parse_an_empty_config_file(void)
cl_assert_equal_i(GIT_ENOTFOUND, git_config_get_int32(&i, cfg, "nope.neither")); cl_assert_equal_i(GIT_ENOTFOUND, git_config_get_int32(&i, cfg, "nope.neither"));
git_config_free(cfg); git_config_free(cfg);
cl_fixture_cleanup("./empty");
} }
void test_config_read__cannot_load_a_non_existing_config_file(void) void test_config_read__cannot_load_a_non_existing_config_file(void)
......
#include "clar_libgit2.h" #include "clar_libgit2.h"
#include "iterator.h" #include "iterator.h"
#include "vector.h" #include "vector.h"
#include "posix.h"
static git_repository *_repo; static git_repository *_repo;
static git_revwalk *_revwalker; static git_revwalk *_revwalker;
...@@ -72,6 +73,21 @@ static void seed_packbuilder(void) ...@@ -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) void test_pack_packbuilder__create_pack(void)
{ {
git_transfer_progress stats; git_transfer_progress stats;
...@@ -82,6 +98,9 @@ void test_pack_packbuilder__create_pack(void) ...@@ -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_new(&_indexer, "testpack.pack"));
cl_git_pass(git_indexer_run(_indexer, &stats)); cl_git_pass(git_indexer_run(_indexer, &stats));
cl_git_pass(git_indexer_write(_indexer)); cl_git_pass(git_indexer_write(_indexer));
cl_fixture_cleanup("testpack.pack");
cleanup_pack(git_indexer_hash(_indexer));
} }
static git_transfer_progress stats; static git_transfer_progress stats;
...@@ -97,10 +116,13 @@ static int foreach_cb(void *buf, size_t len, void *payload) ...@@ -97,10 +116,13 @@ static int foreach_cb(void *buf, size_t len, void *payload)
void test_pack_packbuilder__foreach(void) void test_pack_packbuilder__foreach(void)
{ {
git_indexer_stream *idx; git_indexer_stream *idx;
git_oid oid;
seed_packbuilder(); seed_packbuilder();
cl_git_pass(git_indexer_stream_new(&idx, ".", NULL, NULL)); cl_git_pass(git_indexer_stream_new(&idx, ".", NULL, NULL));
cl_git_pass(git_packbuilder_foreach(_packbuilder, foreach_cb, idx)); cl_git_pass(git_packbuilder_foreach(_packbuilder, foreach_cb, idx));
cl_git_pass(git_indexer_stream_finalize(idx, &stats)); cl_git_pass(git_indexer_stream_finalize(idx, &stats));
git_oid_cpy(&oid, git_indexer_stream_hash(idx));
git_indexer_stream_free(idx); git_indexer_stream_free(idx);
cleanup_pack(&oid);
} }
...@@ -211,6 +211,7 @@ void test_stash_save__cannot_stash_against_a_bare_repository(void) ...@@ -211,6 +211,7 @@ void test_stash_save__cannot_stash_against_a_bare_repository(void)
git_stash_save(&stash_tip_oid, local, signature, NULL, GIT_STASH_DEFAULT)); git_stash_save(&stash_tip_oid, local, signature, NULL, GIT_STASH_DEFAULT));
git_repository_free(local); git_repository_free(local);
cl_fixture_cleanup("sorry-it-is-a-non-bare-only-party");
} }
void test_stash_save__can_stash_against_a_detached_head(void) void test_stash_save__can_stash_against_a_detached_head(void)
......
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