Commit 99dfa470 by Russell Belfer

Some further sandboxing cleanups to tests

Trying to find other issues where tests may not clean up quite
properly when they are through...
parent 0f603132
......@@ -9,11 +9,6 @@ static git_repository *g_repo = NULL;
void test_attr_repo__initialize(void)
{
/* Before each test, instantiate the attr repo from the fixtures and
* rename the .gitted to .git so it is a repo with a working dir.
* Also rename gitattributes to .gitattributes, because it contains
* macro definitions which are only allowed in the root.
*/
g_repo = cl_git_sandbox_init("attr");
}
......
......@@ -493,9 +493,11 @@ void cl_fake_home_cleanup(void *payload)
GIT_UNUSED(payload);
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore));
git__free(restore);
if (restore) {
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore));
git__free(restore);
}
}
void cl_fake_home(void)
......
......@@ -7,10 +7,9 @@ static git_reference *branch;
void test_refs_branches_create__initialize(void)
{
cl_fixture_sandbox("testrepo.git");
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
repo = cl_git_sandbox_init("testrepo.git");
branch = NULL;
target = NULL;
}
void test_refs_branches_create__cleanup(void)
......@@ -21,10 +20,8 @@ void test_refs_branches_create__cleanup(void)
git_commit_free(target);
target = NULL;
git_repository_free(repo);
cl_git_sandbox_cleanup();
repo = NULL;
cl_fixture_cleanup("testrepo.git");
}
static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha)
......
......@@ -10,8 +10,7 @@ void test_refs_branches_delete__initialize(void)
{
git_oid id;
cl_fixture_sandbox("testrepo.git");
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0, NULL, NULL));
......@@ -22,10 +21,8 @@ void test_refs_branches_delete__cleanup(void)
git_reference_free(fake_remote);
fake_remote = NULL;
git_repository_free(repo);
cl_git_sandbox_cleanup();
repo = NULL;
cl_fixture_cleanup("testrepo.git");
}
void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
......
......@@ -7,7 +7,8 @@ static git_reference *branch;
void test_refs_branches_ishead__initialize(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
repo = cl_git_sandbox_init("testrepo.git");
branch = NULL;
}
void test_refs_branches_ishead__cleanup(void)
......@@ -15,7 +16,7 @@ void test_refs_branches_ishead__cleanup(void)
git_reference_free(branch);
branch = NULL;
git_repository_free(repo);
cl_git_sandbox_cleanup();
repo = NULL;
}
......@@ -28,34 +29,20 @@ void test_refs_branches_ishead__can_tell_if_a_branch_is_pointed_at_by_HEAD(void)
void test_refs_branches_ishead__can_properly_handle_unborn_HEAD(void)
{
git_repository_free(repo);
repo = cl_git_sandbox_init("testrepo.git");
make_head_unborn(repo, NON_EXISTING_HEAD);
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
cl_assert_equal_i(false, git_branch_is_head(branch));
cl_git_sandbox_cleanup();
repo = NULL;
}
void test_refs_branches_ishead__can_properly_handle_missing_HEAD(void)
{
git_repository_free(repo);
repo = cl_git_sandbox_init("testrepo.git");
delete_head(repo);
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
cl_assert_equal_i(false, git_branch_is_head(branch));
cl_git_sandbox_cleanup();
repo = NULL;
}
void test_refs_branches_ishead__can_tell_if_a_branch_is_not_pointed_at_by_HEAD(void)
......@@ -95,9 +82,6 @@ void test_refs_branches_ishead__only_direct_references_are_considered(void)
{
git_reference *linked, *super, *head;
git_repository_free(repo);
repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_reference_symbolic_create(&linked, repo, "refs/heads/linked", "refs/heads/master", 0, NULL, NULL));
cl_git_pass(git_reference_symbolic_create(&super, repo, "refs/heads/super", "refs/heads/linked", 0, NULL, NULL));
cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/heads/super", 1, NULL, NULL));
......@@ -111,6 +95,4 @@ void test_refs_branches_ishead__only_direct_references_are_considered(void)
git_reference_free(linked);
git_reference_free(super);
git_reference_free(head);
cl_git_sandbox_cleanup();
repo = NULL;
}
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