summaryrefslogtreecommitdiff
path: root/tests-clar/submodule
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-09-13 09:26:26 -0700
committerRussell Belfer <rb@github.com>2013-09-17 09:31:45 -0700
commitd5b1866cc363461c3ecc14412dcd26d2e4fa8b68 (patch)
tree7ac408777de075d60039e1628489cecb86b83b50 /tests-clar/submodule
parentb47349b8dc742943e063cb3d755b9db66203e3d9 (diff)
downloadlibgit2-d5b1866cc363461c3ecc14412dcd26d2e4fa8b68.tar.gz
Rearrange clar submodule cleanup code
Diffstat (limited to 'tests-clar/submodule')
-rw-r--r--tests-clar/submodule/status.c1
-rw-r--r--tests-clar/submodule/submodule_helpers.c21
-rw-r--r--tests-clar/submodule/submodule_helpers.h2
3 files changed, 13 insertions, 11 deletions
diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c
index 7b29ac288..f1227a575 100644
--- a/tests-clar/submodule/status.c
+++ b/tests-clar/submodule/status.c
@@ -14,7 +14,6 @@ void test_submodule_status__initialize(void)
void test_submodule_status__cleanup(void)
{
- cleanup_fixture_submodules();
}
void test_submodule_status__unchanged(void)
diff --git a/tests-clar/submodule/submodule_helpers.c b/tests-clar/submodule/submodule_helpers.c
index a7807522b..3e79c77fd 100644
--- a/tests-clar/submodule/submodule_helpers.c
+++ b/tests-clar/submodule/submodule_helpers.c
@@ -83,6 +83,14 @@ void rewrite_gitmodules(const char *workdir)
git_buf_free(&path);
}
+static void cleanup_fixture_submodules(void *payload)
+{
+ cl_git_sandbox_cleanup(); /* either "submodules" or "submod2" */
+
+ if (payload)
+ cl_fixture_cleanup(payload);
+}
+
git_repository *setup_fixture_submodules(void)
{
git_repository *repo = cl_git_sandbox_init("submodules");
@@ -92,6 +100,8 @@ git_repository *setup_fixture_submodules(void)
rewrite_gitmodules(git_repository_workdir(repo));
p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git");
+ cl_set_cleanup(cleanup_fixture_submodules, "testrepo.git");
+
return repo;
}
@@ -106,14 +116,7 @@ git_repository *setup_fixture_submod2(void)
p_rename("submod2/not-submodule/.gitted", "submod2/not-submodule/.git");
p_rename("submod2/not/.gitted", "submod2/not/.git");
- return repo;
-}
+ cl_set_cleanup(cleanup_fixture_submodules, "submod2_target");
-void cleanup_fixture_submodules(void)
-{
- cl_git_sandbox_cleanup();
-
- /* just try to clean up both possible extras */
- cl_fixture_cleanup("testrepo.git");
- cl_fixture_cleanup("submod2_target");
+ return repo;
}
diff --git a/tests-clar/submodule/submodule_helpers.h b/tests-clar/submodule/submodule_helpers.h
index 1de15ca17..610c40720 100644
--- a/tests-clar/submodule/submodule_helpers.h
+++ b/tests-clar/submodule/submodule_helpers.h
@@ -1,5 +1,5 @@
extern void rewrite_gitmodules(const char *workdir);
+/* these will automatically set a cleanup callback */
extern git_repository *setup_fixture_submodules(void);
extern git_repository *setup_fixture_submod2(void);
-extern void cleanup_fixture_submodules(void);