Cleanup after tests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/tests-clar/config/read.c b/tests-clar/config/read.c
index e0171a5..d2ad0de 100644
--- a/tests-clar/config/read.c
+++ b/tests-clar/config/read.c
@@ -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"));
git_config_free(cfg);
+ cl_fixture_cleanup("./empty");
}
void test_config_read__cannot_load_a_non_existing_config_file(void)
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c
index b450be6..31823ea 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);
}
diff --git a/tests-clar/stash/save.c b/tests-clar/stash/save.c
index f8b4278..2302ebb 100644
--- a/tests-clar/stash/save.c
+++ b/tests-clar/stash/save.c
@@ -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_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)