diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-01-17 15:56:34 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-01-17 15:56:34 +0100 |
commit | 43a34f9f74fdce462fa250baab620264c28b6165 (patch) | |
tree | 4626c150935791d87ea175fa662d40b79e4ba634 /src/testdir/test_delete.vim | |
parent | 4119cf80e1e534057680f9543e73edf7967c2440 (diff) | |
download | vim-43a34f9f74fdce462fa250baab620264c28b6165.zip |
patch 7.4.1114
Problem: delete() does not work well with symbolic links.
Solution: Recognize symbolik links.
Diffstat (limited to 'src/testdir/test_delete.vim')
-rw-r--r-- | src/testdir/test_delete.vim | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/testdir/test_delete.vim b/src/testdir/test_delete.vim index 6e2b9c86b..13c87a152 100644 --- a/src/testdir/test_delete.vim +++ b/src/testdir/test_delete.vim @@ -34,3 +34,64 @@ func Test_recursive_delete() call assert_false(isdirectory('Xdir1')) call assert_equal(-1, delete('Xdir1', 'd')) endfunc + +func Test_symlink_delete() + if !has('unix') + return + endif + split Xfile + call setline(1, ['a', 'b']) + wq + silent !ln -s Xfile Xlink + " Delete the link, not the file + call assert_equal(0, delete('Xlink')) + call assert_equal(-1, delete('Xlink')) + call assert_equal(0, delete('Xfile')) +endfunc + +func Test_symlink_dir_delete() + if !has('unix') + return + endif + call mkdir('Xdir1') + silent !ln -s Xdir1 Xlink + call assert_true(isdirectory('Xdir1')) + call assert_true(isdirectory('Xlink')) + " Delete the link, not the directory + call assert_equal(0, delete('Xlink')) + call assert_equal(-1, delete('Xlink')) + call assert_equal(0, delete('Xdir1', 'd')) +endfunc + +func Test_symlink_recursive_delete() + if !has('unix') + return + endif + call mkdir('Xdir3') + call mkdir('Xdir3/subdir') + call mkdir('Xdir4') + split Xdir3/Xfile + call setline(1, ['a', 'b']) + w + w Xdir3/subdir/Xfile + w Xdir4/Xfile + close + silent !ln -s ../Xdir4 Xdir3/Xlink + + call assert_true(isdirectory('Xdir3')) + call assert_equal(['a', 'b'], readfile('Xdir3/Xfile')) + call assert_true(isdirectory('Xdir3/subdir')) + call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile')) + call assert_true(isdirectory('Xdir4')) + call assert_true(isdirectory('Xdir3/Xlink')) + call assert_equal(['a', 'b'], readfile('Xdir4/Xfile')) + + call assert_equal(0, delete('Xdir3', 'rf')) + call assert_false(isdirectory('Xdir3')) + call assert_equal(-1, delete('Xdir3', 'd')) + " symlink is deleted, not the directory it points to + call assert_true(isdirectory('Xdir4')) + call assert_equal(['a', 'b'], readfile('Xdir4/Xfile')) + call assert_equal(0, delete('Xdir4/Xfile')) + call assert_equal(0, delete('Xdir4', 'd')) +endfunc |