summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurence McGlashan <laurence.mcglashan@gmail.com>2021-09-14 12:34:45 +0100
committerLaurence McGlashan <laurence.mcglashan@gmail.com>2021-09-14 12:34:45 +0100
commit6cf9a0b3ee341b8f56be7c1de4f2b23e98c28bbd (patch)
tree4b85f49b69a2c0611ceb7ebaf9d329b26808bd2a
parent26bf94c07b444a10108086174513e50e42fb9d4c (diff)
downloadlibgit2-6cf9a0b3ee341b8f56be7c1de4f2b23e98c28bbd.tar.gz
Refactor shared code in longpath test.
-rw-r--r--tests/win32/longpath.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
index 4bc8a837d..294faea99 100644
--- a/tests/win32/longpath.c
+++ b/tests/win32/longpath.c
@@ -64,15 +64,11 @@ void test_win32_longpath__workdir_path_validated(void)
#endif
}
-void test_win32_longpath__status_and_add(void)
-{
-#ifdef GIT_WIN32
- git_repository *repo = cl_git_sandbox_init("testrepo");
+static void assert_longpath_status_and_add(git_repository* repo) {
git_index *index;
git_buf out = GIT_BUF_INIT;
unsigned int status_flags;
- cl_repo_set_bool(repo, "core.longpaths", true);
cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
@@ -88,33 +84,27 @@ void test_win32_longpath__status_and_add(void)
git_index_free(index);
git_buf_dispose(&out);
-#endif
}
-void test_win32_longpath__status_and_add_with_filter(void)
+void test_win32_longpath__status_and_add(void)
{
#ifdef GIT_WIN32
git_repository *repo = cl_git_sandbox_init("testrepo");
- git_index *index;
- git_buf out = GIT_BUF_INIT;
- unsigned int status_flags;
cl_repo_set_bool(repo, "core.longpaths", true);
- cl_repo_set_bool(repo, "core.autocrlf", true);
- cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
- cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
-
- cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
- cl_assert_equal_i(GIT_STATUS_WT_NEW, status_flags);
+ assert_longpath_status_and_add(repo);
+#endif
+}
- cl_git_pass(git_repository_index(&index, repo));
- cl_git_pass(git_index_add_bypath(index, LONG_FILENAME));
+void test_win32_longpath__status_and_add_with_filter(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo = cl_git_sandbox_init("testrepo");
- cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
- cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status_flags);
+ cl_repo_set_bool(repo, "core.longpaths", true);
+ cl_repo_set_bool(repo, "core.autocrlf", true);
- git_index_free(index);
- git_buf_dispose(&out);
+ assert_longpath_status_and_add(repo);
#endif
}