mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
tests: do_rmdir(): improve error handling #10955
This commit is contained in:

committed by
Justin M. Keyes

parent
1dab52f878
commit
fd8b00bacd
@@ -577,8 +577,16 @@ function module.assert_alive()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function do_rmdir(path)
|
local function do_rmdir(path)
|
||||||
if lfs.attributes(path, 'mode') ~= 'directory' then
|
local mode, errmsg, errcode = lfs.attributes(path, 'mode')
|
||||||
return -- Don't complain.
|
if mode == nil then
|
||||||
|
if errcode == 2 then
|
||||||
|
-- "No such file or directory", don't complain.
|
||||||
|
return
|
||||||
|
end
|
||||||
|
error(string.format('rmdir: %s (%d)', errmsg, errcode))
|
||||||
|
end
|
||||||
|
if mode ~= 'directory' then
|
||||||
|
error(string.format('rmdir: not a directory: %s', path))
|
||||||
end
|
end
|
||||||
for file in lfs.dir(path) do
|
for file in lfs.dir(path) do
|
||||||
if file ~= '.' and file ~= '..' then
|
if file ~= '.' and file ~= '..' then
|
||||||
|
Reference in New Issue
Block a user