diff src/testdir/test_functions.vim @ 20790:5a9c42c6a69e v8.2.0947

patch 8.2.0947: readdirex() doesn't handle broken link properly Commit: https://github.com/vim/vim/commit/ab54032f297e9418b0d83970cbe3a414d6ef08c4 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 10 15:55:36 2020 +0200 patch 8.2.0947: readdirex() doesn't handle broken link properly Problem: Readdirex() doesn't handle broken link properly. Solution: Small fixes to readdirex(). (Christian Brabandt, closes https://github.com/vim/vim/issues/6226, closes #6213)
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jun 2020 16:00:05 +0200
parents 072ad890c227
children 2e7acc208a1f
line wrap: on
line diff
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1912,6 +1912,16 @@ func Test_readdirex()
 			  \ ->map({-> v:val.name})
   call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
 
+  " report brocken link correctly
+  if has("unix")
+    call writefile([], 'Xdir/abc.txt')
+    call system("ln -s Xdir/abc.txt Xdir/link")
+    call delete('Xdir/abc.txt')
+    let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []')
+			  \ ->map({-> v:val.name .. '_' .. v:val.type})
+    call sort(files)->assert_equal(
+        \ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link'])
+  endif
   eval 'Xdir'->delete('rf')
 endfunc