Commit de412fc29918ed2cb11e2e9beeb15f7890668bdf

Patrick Steinhardt 2019-10-17T13:36:22

tests: submodule: make use of sandboxes to clean repos The test submodule::add::submodule_clone doesn't use a sandbox, and thus the created repo will not get deleted after the test has finished. Convert the test to use the empty standard repo sandbox instead to fix this.

diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index e79d079..76c3fff 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -187,28 +187,28 @@ void test_submodule_add__file_exists_in_index(void)
 
 void test_submodule_add__submodule_clone(void)
 {
-	git_index *index;
 	git_oid tree_id, commit_id;
-	git_submodule *sm;
 	git_signature *sig;
+	git_submodule *sm;
+	git_index *index;
 
-	cl_git_pass(git_repository_init(&g_repo, "willaddsubmodule-add", false));
+	g_repo = cl_git_sandbox_init("empty_standard_repo");
 
 	/* Create the submodule structure, clone into it and finalize */
 	cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "testrepo-add", true));
 	cl_git_pass(git_submodule_clone(NULL, sm, NULL));
 	cl_git_pass(git_submodule_add_finalize(sm));
-	git_submodule_free(sm);
 
+	/* Create the submodule commit */
 	cl_git_pass(git_repository_index(&index, g_repo));
 	cl_git_pass(git_index_write_tree(&tree_id, index));
-	git_index_free(index);
-
 	cl_git_pass(git_signature_now(&sig, "Submoduler", "submoduler@local"));
 	cl_git_pass(git_commit_create_from_ids(&commit_id, g_repo, "HEAD", sig, sig, NULL, "A submodule\n",
-										   &tree_id, 0, NULL));
-
-	git_signature_free(sig);
+					       &tree_id, 0, NULL));
 
 	assert_submodule_exists(g_repo, "testrepo-add");
+
+	git_signature_free(sig);
+	git_submodule_free(sm);
+	git_index_free(index);
 }