mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 13:10:44 +00:00
Problem: Delete() can not handle a file name that looks like a pattern.
Solution: Use readdir() instead of appending "/*" and expanding wildcards.
(Ken Takata, closes vim/vim#4424, closes vim/vim#696)
701ff0a3e5
40 lines
1.0 KiB
Lua
40 lines
1.0 KiB
Lua
local helpers = require('test.functional.helpers')(after_each)
|
|
local clear, source = helpers.clear, helpers.source
|
|
local eq, eval, command = helpers.eq, helpers.eval, helpers.command
|
|
|
|
describe('Test for delete()', function()
|
|
before_each(clear)
|
|
after_each(function()
|
|
os.remove('Xfile')
|
|
end)
|
|
|
|
it('file delete', function()
|
|
command('split Xfile')
|
|
command("call setline(1, ['a', 'b'])")
|
|
command('wq')
|
|
eq(eval("['a', 'b']"), eval("readfile('Xfile')"))
|
|
eq(0, eval("delete('Xfile')"))
|
|
eq(-1, eval("delete('Xfile')"))
|
|
end)
|
|
|
|
it('symlink delete', function()
|
|
source([[
|
|
split Xfile
|
|
call setline(1, ['a', 'b'])
|
|
wq
|
|
if has('win32')
|
|
silent !mklink Xlink Xfile
|
|
else
|
|
silent !ln -s Xfile Xlink
|
|
endif
|
|
]])
|
|
if eval('v:shell_error') ~= 0 then
|
|
pending('Cannot create symlink')
|
|
end
|
|
-- Delete the link, not the file
|
|
eq(0, eval("delete('Xlink')"))
|
|
eq(-1, eval("delete('Xlink')"))
|
|
eq(0, eval("delete('Xfile')"))
|
|
end)
|
|
end)
|