Skip to content

Commit de412fc

Browse files
committed
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.
1 parent 09b1ac1 commit de412fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/submodule/add.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,28 +187,28 @@ void test_submodule_add__file_exists_in_index(void)
187187

188188
void test_submodule_add__submodule_clone(void)
189189
{
190-
git_index *index;
191190
git_oid tree_id, commit_id;
192-
git_submodule *sm;
193191
git_signature *sig;
192+
git_submodule *sm;
193+
git_index *index;
194194

195-
cl_git_pass(git_repository_init(&g_repo, "willaddsubmodule-add", false));
195+
g_repo = cl_git_sandbox_init("empty_standard_repo");
196196

197197
/* Create the submodule structure, clone into it and finalize */
198198
cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "testrepo-add", true));
199199
cl_git_pass(git_submodule_clone(NULL, sm, NULL));
200200
cl_git_pass(git_submodule_add_finalize(sm));
201-
git_submodule_free(sm);
202201

202+
/* Create the submodule commit */
203203
cl_git_pass(git_repository_index(&index, g_repo));
204204
cl_git_pass(git_index_write_tree(&tree_id, index));
205-
git_index_free(index);
206-
207205
cl_git_pass(git_signature_now(&sig, "Submoduler", "submoduler@local"));
208206
cl_git_pass(git_commit_create_from_ids(&commit_id, g_repo, "HEAD", sig, sig, NULL, "A submodule\n",
209-
&tree_id, 0, NULL));
210-
211-
git_signature_free(sig);
207+
&tree_id, 0, NULL));
212208

213209
assert_submodule_exists(g_repo, "testrepo-add");
210+
211+
git_signature_free(sig);
212+
git_submodule_free(sm);
213+
git_index_free(index);
214214
}

0 commit comments

Comments
 (0)