summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/filebuf.c15
-rw-r--r--tests/core/futils.c21
-rw-r--r--tests/core/posix.c22
3 files changed, 49 insertions, 9 deletions
diff --git a/tests/core/filebuf.c b/tests/core/filebuf.c
index 8d1952f57..e527ce97c 100644
--- a/tests/core/filebuf.c
+++ b/tests/core/filebuf.c
@@ -157,9 +157,8 @@ void test_core_filebuf__symlink_follow(void)
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
-#ifdef GIT_WIN32
- cl_skip();
-#endif
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ cl_skip();
cl_git_pass(p_mkdir(dir, 0777));
cl_git_pass(p_symlink("target", source));
@@ -192,9 +191,8 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
git_filebuf file = GIT_FILEBUF_INIT;
git_buf source = GIT_BUF_INIT, target = GIT_BUF_INIT;
-#ifdef GIT_WIN32
- cl_skip();
-#endif
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ cl_skip();
cl_git_pass(git_buf_joinpath(&source, clar_sandbox_path(), "linkdir/link"));
cl_git_pass(git_buf_joinpath(&target, clar_sandbox_path(), "linkdir/target"));
@@ -221,9 +219,8 @@ void test_core_filebuf__symlink_depth(void)
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
-#ifdef GIT_WIN32
- cl_skip();
-#endif
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ cl_skip();
cl_git_pass(p_mkdir(dir, 0777));
/* Endless loop */
diff --git a/tests/core/futils.c b/tests/core/futils.c
index 82c9b24c7..2c8294c87 100644
--- a/tests/core/futils.c
+++ b/tests/core/futils.c
@@ -66,3 +66,24 @@ void test_core_futils__write_hidden_file(void)
#endif
}
+void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
+{
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ cl_skip();
+
+ cl_git_pass(git_futils_mkdir_r("a/b", 0777));
+ cl_git_pass(git_futils_mkdir_r("dir-target", 0777));
+ cl_git_mkfile("dir-target/file", "Contents");
+ cl_git_mkfile("file-target", "Contents");
+ cl_must_pass(p_symlink("dir-target", "a/symlink"));
+ cl_must_pass(p_symlink("file-target", "a/b/symlink"));
+
+ cl_git_pass(git_futils_rmdir_r("a", NULL, GIT_RMDIR_REMOVE_FILES));
+
+ cl_assert(git_path_exists("dir-target"));
+ cl_assert(git_path_exists("file-target"));
+
+ cl_must_pass(p_unlink("dir-target/file"));
+ cl_must_pass(p_rmdir("dir-target"));
+ cl_must_pass(p_unlink("file-target"));
+}
diff --git a/tests/core/posix.c b/tests/core/posix.c
index 795be31b8..10d689a5f 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -12,6 +12,7 @@
#include <locale.h>
#include "clar_libgit2.h"
+#include "futils.h"
#include "posix.h"
#include "userdiff.h"
@@ -263,3 +264,24 @@ void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
cl_assert(!error);
}
}
+
+void test_core_posix__unlink_removes_symlink(void)
+{
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ clar__skip();
+
+ cl_git_mkfile("file", "Dummy file.");
+ cl_git_pass(git_futils_mkdir("dir", 0777, 0));
+
+ cl_must_pass(p_symlink("file", "file-symlink"));
+ cl_must_pass(p_symlink("dir", "dir-symlink"));
+
+ cl_must_pass(p_unlink("file-symlink"));
+ cl_must_pass(p_unlink("dir-symlink"));
+
+ cl_assert(git_path_exists("file"));
+ cl_assert(git_path_exists("dir"));
+
+ cl_must_pass(p_unlink("file"));
+ cl_must_pass(p_rmdir("dir"));
+}