Commit b6ed67c224a7b22629bca579d893d368e12f8cd9

Patrick Steinhardt 2017-05-10T12:54:14

tests: refs::crashes: create sandbox for creating symref The test `refs::crashes::double_free` operates on our in-source "testrepo.git" repository without creating a copy first. As the test will try to create a new symbolic reference, this will fail when we want to do a pure out-of-tree build with a read-only source tree. Fix the issue by creating a sandbox first.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/tests/refs/crashes.c b/tests/refs/crashes.c
index 7a10411..228f479 100644
--- a/tests/refs/crashes.c
+++ b/tests/refs/crashes.c
@@ -6,7 +6,7 @@ void test_refs_crashes__double_free(void)
 	git_reference *ref, *ref2;
 	const char *REFNAME = "refs/heads/xxx";
 
-	cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+	repo = cl_git_sandbox_init("testrepo.git");
 	cl_git_pass(git_reference_symbolic_create(&ref, repo, REFNAME, "refs/heads/master", 0, NULL));
 	cl_git_pass(git_reference_lookup(&ref2, repo, REFNAME));
 	cl_git_pass(git_reference_delete(ref));
@@ -16,5 +16,5 @@ void test_refs_crashes__double_free(void)
 	/* reference is gone from disk, so reloading it will fail */
 	cl_git_fail(git_reference_lookup(&ref2, repo, REFNAME));
 
-	git_repository_free(repo);
+	cl_git_sandbox_cleanup();
 }