diff src/testdir/test_functions.vim @ 35459:d31e86eb4c4b v9.1.0499

patch 9.1.0499: MS-Windows: doesn't handle symlinks properly Commit: https://github.com/vim/vim/commit/23c5ebeb95cb942df307946e3ced230a7c8312eb Author: LemonBoy <thatlemon@gmail.com> Date: Tue Jun 18 20:43:51 2024 +0200 patch 9.1.0499: MS-Windows: doesn't handle symlinks properly Problem: MS-Windows: doesn't handle symlinks properly (Timothy Madden) Solution: Implement lstat() on MS-Windows (author) lstat() differs from stat() in how it handles symbolic links, the former doesn't resolve the symlink while the latter does so. Implement a simple yet effective fallback using Win32 APIs. fixes #14933 closes: #15014 Co-authored-by: K.Takata <kentkt@csc.jp> Signed-off-by: LemonBoy <thatlemon@gmail.com> Signed-off-by: K.Takata <kentkt@csc.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 18 Jun 2024 21:00:03 +0200
parents 022f3d5af451
children 04563887d70e
line wrap: on
line diff
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -3822,6 +3822,29 @@ func Test_glob2()
   endif
 endfunc
 
+func Test_glob_symlinks()
+  call writefile([], 'Xglob1')
+
+  if has("win32")
+    silent !mklink XglobBad DoesNotExist
+    if v:shell_error
+      throw 'Skipped: cannot create symlinks'
+    endif
+    silent !mklink XglobOk Xglob1
+  else
+    silent !ln -s DoesNotExist XglobBad
+    silent !ln -s Xglob1 XglobOk
+  endif
+
+  " The broken symlink is excluded when alllinks is false.
+  call assert_equal(['Xglob1', 'XglobBad', 'XglobOk'], sort(glob('Xglob*', 0, 1, 1)))
+  call assert_equal(['Xglob1', 'XglobOk'], sort(glob('Xglob*', 0, 1, 0)))
+
+  call delete('Xglob1')
+  call delete('XglobBad')
+  call delete('XglobOk')
+endfunc
+
 " Test for browse()
 func Test_browse()
   CheckFeature browse