Some further sandboxing cleanups to tests Trying to find other issues where tests may not clean up quite properly when they are through...
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index 9aab7ed..5e812a7 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -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");
}
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 9ec9a64..f457adb 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -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)
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index b91eed6..38af2f6 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -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)
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index ed5f162..e3199e2 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -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)
diff --git a/tests/refs/branches/ishead.c b/tests/refs/branches/ishead.c
index 12a8c44..d16a796 100644
--- a/tests/refs/branches/ishead.c
+++ b/tests/refs/branches/ishead.c
@@ -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;
}