File tree Expand file tree Collapse file tree 3 files changed +49
-9
lines changed
Expand file tree Collapse file tree 3 files changed +49
-9
lines changed Original file line number Diff line number Diff line change @@ -157,9 +157,8 @@ void test_core_filebuf__symlink_follow(void)
157157 git_filebuf file = GIT_FILEBUF_INIT ;
158158 const char * dir = "linkdir" , * source = "linkdir/link" ;
159159
160- #ifdef GIT_WIN32
161- cl_skip ();
162- #endif
160+ if (!git_path_supports_symlinks (clar_sandbox_path ()))
161+ cl_skip ();
163162
164163 cl_git_pass (p_mkdir (dir , 0777 ));
165164 cl_git_pass (p_symlink ("target" , source ));
@@ -192,9 +191,8 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
192191 git_filebuf file = GIT_FILEBUF_INIT ;
193192 git_buf source = GIT_BUF_INIT , target = GIT_BUF_INIT ;
194193
195- #ifdef GIT_WIN32
196- cl_skip ();
197- #endif
194+ if (!git_path_supports_symlinks (clar_sandbox_path ()))
195+ cl_skip ();
198196
199197 cl_git_pass (git_buf_joinpath (& source , clar_sandbox_path (), "linkdir/link" ));
200198 cl_git_pass (git_buf_joinpath (& target , clar_sandbox_path (), "linkdir/target" ));
@@ -221,9 +219,8 @@ void test_core_filebuf__symlink_depth(void)
221219 git_filebuf file = GIT_FILEBUF_INIT ;
222220 const char * dir = "linkdir" , * source = "linkdir/link" ;
223221
224- #ifdef GIT_WIN32
225- cl_skip ();
226- #endif
222+ if (!git_path_supports_symlinks (clar_sandbox_path ()))
223+ cl_skip ();
227224
228225 cl_git_pass (p_mkdir (dir , 0777 ));
229226 /* Endless loop */
Original file line number Diff line number Diff line change @@ -66,3 +66,24 @@ void test_core_futils__write_hidden_file(void)
6666#endif
6767}
6868
69+ void test_core_futils__recursive_rmdir_keeps_symlink_targets (void )
70+ {
71+ if (!git_path_supports_symlinks (clar_sandbox_path ()))
72+ cl_skip ();
73+
74+ cl_git_pass (git_futils_mkdir_r ("a/b" , 0777 ));
75+ cl_git_pass (git_futils_mkdir_r ("dir-target" , 0777 ));
76+ cl_git_mkfile ("dir-target/file" , "Contents" );
77+ cl_git_mkfile ("file-target" , "Contents" );
78+ cl_must_pass (p_symlink ("dir-target" , "a/symlink" ));
79+ cl_must_pass (p_symlink ("file-target" , "a/b/symlink" ));
80+
81+ cl_git_pass (git_futils_rmdir_r ("a" , NULL , GIT_RMDIR_REMOVE_FILES ));
82+
83+ cl_assert (git_path_exists ("dir-target" ));
84+ cl_assert (git_path_exists ("file-target" ));
85+
86+ cl_must_pass (p_unlink ("dir-target/file" ));
87+ cl_must_pass (p_rmdir ("dir-target" ));
88+ cl_must_pass (p_unlink ("file-target" ));
89+ }
Original file line number Diff line number Diff line change 1212#include <locale.h>
1313
1414#include "clar_libgit2.h"
15+ #include "futils.h"
1516#include "posix.h"
1617#include "userdiff.h"
1718
@@ -263,3 +264,24 @@ void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
263264 cl_assert (!error );
264265 }
265266}
267+
268+ void test_core_posix__unlink_removes_symlink (void )
269+ {
270+ if (!git_path_supports_symlinks (clar_sandbox_path ()))
271+ clar__skip ();
272+
273+ cl_git_mkfile ("file" , "Dummy file." );
274+ cl_git_pass (git_futils_mkdir ("dir" , 0777 , 0 ));
275+
276+ cl_must_pass (p_symlink ("file" , "file-symlink" ));
277+ cl_must_pass (p_symlink ("dir" , "dir-symlink" ));
278+
279+ cl_must_pass (p_unlink ("file-symlink" ));
280+ cl_must_pass (p_unlink ("dir-symlink" ));
281+
282+ cl_assert (git_path_exists ("file" ));
283+ cl_assert (git_path_exists ("dir" ));
284+
285+ cl_must_pass (p_unlink ("file" ));
286+ cl_must_pass (p_rmdir ("dir" ));
287+ }
You can’t perform that action at this time.
0 commit comments