Commit 09a03995 by Ben Straub

Checkout: make core.symlinks test work on OSX.

parent 8651c10f
...@@ -28,8 +28,10 @@ static void test_file_contents(const char *path, const char *expectedcontents) ...@@ -28,8 +28,10 @@ static void test_file_contents(const char *path, const char *expectedcontents)
{ {
int fd; int fd;
char buffer[1024] = {0}; char buffer[1024] = {0};
fd = p_open(path, O_RDONLY); fd = p_open(path, O_RDONLY);
cl_assert(fd >= 0); cl_assert(fd >= 0);
cl_assert_equal_i(p_read(fd, buffer, 1024), strlen(expectedcontents)); cl_assert_equal_i(p_read(fd, buffer, 1024), strlen(expectedcontents));
cl_assert_equal_s(expectedcontents, buffer); cl_assert_equal_s(expectedcontents, buffer);
cl_git_pass(p_close(fd)); cl_git_pass(p_close(fd));
...@@ -70,14 +72,18 @@ void test_checkout_checkout__stats(void) ...@@ -70,14 +72,18 @@ void test_checkout_checkout__stats(void)
/* TODO */ /* TODO */
} }
void test_checkout_checkout__symlinks(void) static void enable_symlinks(bool enable)
{ {
git_config *cfg; git_config *cfg;
cl_git_pass(git_repository_config(&cfg, g_repo)); cl_git_pass(git_repository_config(&cfg, g_repo));
cl_git_pass(git_config_set_bool(cfg, "core.symlinks", enable));
git_config_free(cfg);
}
void test_checkout_checkout__symlinks(void)
{
/* First try with symlinks forced on */ /* First try with symlinks forced on */
cl_git_pass(git_config_set_bool(cfg, "core.symlinks", true)); enable_symlinks(true);
cl_git_pass(git_checkout_force(g_repo, NULL)); cl_git_pass(git_checkout_force(g_repo, NULL));
#ifdef GIT_WIN32 #ifdef GIT_WIN32
...@@ -96,7 +102,9 @@ void test_checkout_checkout__symlinks(void) ...@@ -96,7 +102,9 @@ void test_checkout_checkout__symlinks(void)
#endif #endif
/* Now with symlinks forced off */ /* Now with symlinks forced off */
cl_git_pass(git_config_set_bool(cfg, "core.symlinks", false)); cl_git_sandbox_cleanup();
g_repo = cl_git_sandbox_init("testrepo");
enable_symlinks(false);
cl_git_pass(git_checkout_force(g_repo, NULL)); cl_git_pass(git_checkout_force(g_repo, NULL));
test_file_contents("./testrepo/link_to_new.txt", "new.txt"); test_file_contents("./testrepo/link_to_new.txt", "new.txt");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment