Skip to content

Commit 6ee7d37

Browse files
committed
tests: index::tests: create sandboxed repo for locking
The test `index::tests::can_lock_index` operates on the "testrepo.git" repository located inside of our source tree. While this is okay for tests which do read-only operations on these resouces, this specific test tries to lock the index by creating a lock. This will obviously fail on out-of-tree builds with read-only source trees. Fix the issue by creating a sandbox first.
1 parent 4305fcc commit 6ee7d37

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/index/tests.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,14 @@ void test_index_tests__change_icase_on_instance(void)
856856

857857
void test_index_tests__can_lock_index(void)
858858
{
859+
git_repository *repo;
859860
git_index *index;
860861
git_indexwriter one = GIT_INDEXWRITER_INIT,
861862
two = GIT_INDEXWRITER_INIT;
862863

863-
cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
864+
repo = cl_git_sandbox_init("testrepo.git");
865+
866+
cl_git_pass(git_repository_index(&index, repo));
864867
cl_git_pass(git_indexwriter_init(&one, index));
865868

866869
cl_git_fail_with(GIT_ELOCKED, git_indexwriter_init(&two, index));
@@ -873,4 +876,5 @@ void test_index_tests__can_lock_index(void)
873876
git_indexwriter_cleanup(&one);
874877
git_indexwriter_cleanup(&two);
875878
git_index_free(index);
879+
cl_git_sandbox_cleanup();
876880
}

0 commit comments

Comments
 (0)