summaryrefslogtreecommitdiff
path: root/tests/index/tests.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-10 12:51:06 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-23 15:17:44 +0200
commit6ee7d37adc4acfdd0990b694d14cf94b3f284fc3 (patch)
treea3cce6fffebd0d167f744674a8aebeb7d2d46176 /tests/index/tests.c
parent4305fcca1bbc8ee9f84df898c1124ac1db0a5e97 (diff)
downloadlibgit2-6ee7d37adc4acfdd0990b694d14cf94b3f284fc3.tar.gz
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.
Diffstat (limited to 'tests/index/tests.c')
-rw-r--r--tests/index/tests.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 1498196b2..ea8335b48 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -856,11 +856,14 @@ void test_index_tests__change_icase_on_instance(void)
void test_index_tests__can_lock_index(void)
{
+ git_repository *repo;
git_index *index;
git_indexwriter one = GIT_INDEXWRITER_INIT,
two = GIT_INDEXWRITER_INIT;
- cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
+ repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_indexwriter_init(&one, index));
cl_git_fail_with(GIT_ELOCKED, git_indexwriter_init(&two, index));
@@ -873,4 +876,5 @@ void test_index_tests__can_lock_index(void)
git_indexwriter_cleanup(&one);
git_indexwriter_cleanup(&two);
git_index_free(index);
+ cl_git_sandbox_cleanup();
}