Test has to work on case sensitive systems
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
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 53d45a8..1bc5e6a 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -422,12 +422,15 @@ void test_index_tests__preserves_case(void)
git_repository *repo;
git_index *index;
const git_index_entry *entry;
+ int index_caps;
cl_set_cleanup(&cleanup_myrepo, NULL);
cl_git_pass(git_repository_init(&repo, "./myrepo", 0));
cl_git_pass(git_repository_index(&index, repo));
+ index_caps = git_index_caps(index);
+
cl_git_rewritefile("myrepo/test.txt", "hey there\n");
cl_git_pass(git_index_add_bypath(index, "test.txt"));
@@ -435,15 +438,23 @@ void test_index_tests__preserves_case(void)
cl_git_rewritefile("myrepo/TEST.txt", "hello again\n");
cl_git_pass(git_index_add_bypath(index, "TEST.txt"));
- cl_assert(git_index_entrycount(index) == 1);
+ if (index_caps & GIT_INDEXCAP_IGNORE_CASE)
+ cl_assert_equal_i(1, (int)git_index_entrycount(index));
+ else
+ cl_assert_equal_i(2, (int)git_index_entrycount(index));
/* Test access by path instead of index */
cl_assert((entry = git_index_get_bypath(index, "test.txt", 0)) != NULL);
- cl_assert((entry = git_index_get_bypath(index, "TEST.txt", 0)) != NULL);
-
/* The path should *not* have changed without an explicit remove */
cl_assert(git__strcmp(entry->path, "test.txt") == 0);
+ cl_assert((entry = git_index_get_bypath(index, "TEST.txt", 0)) != NULL);
+ if (index_caps & GIT_INDEXCAP_IGNORE_CASE)
+ /* The path should *not* have changed without an explicit remove */
+ cl_assert(git__strcmp(entry->path, "test.txt") == 0);
+ else
+ cl_assert(git__strcmp(entry->path, "TEST.txt") == 0);
+
git_index_free(index);
git_repository_free(repo);
}