mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
test/helpers.rmdir(): Windows: Change to top-level dir on failure.
On Windows, if the nvim process has a directory open the lua process cannot remove it. After failing once, it's safe to force `nvim` to the top-level directory. Then try again.
This commit is contained in:
parent
e43f7425ee
commit
a63675c384
@ -14,6 +14,7 @@ local neq = global_helpers.neq
|
|||||||
local eq = global_helpers.eq
|
local eq = global_helpers.eq
|
||||||
local ok = global_helpers.ok
|
local ok = global_helpers.ok
|
||||||
|
|
||||||
|
local start_dir = lfs.currentdir()
|
||||||
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
||||||
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.',
|
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.',
|
||||||
@ -475,6 +476,12 @@ end
|
|||||||
|
|
||||||
local function rmdir(path)
|
local function rmdir(path)
|
||||||
local ret, _ = pcall(do_rmdir, path)
|
local ret, _ = pcall(do_rmdir, path)
|
||||||
|
if not ret and os_name() == "windows" then
|
||||||
|
-- Maybe "Permission denied"; try again after changing the nvim
|
||||||
|
-- process to the top-level directory.
|
||||||
|
nvim_command([[exe 'cd '.fnameescape(']]..start_dir.."')")
|
||||||
|
ret, _ = pcall(do_rmdir, path)
|
||||||
|
end
|
||||||
-- During teardown, the nvim process may not exit quickly enough, then rmdir()
|
-- During teardown, the nvim process may not exit quickly enough, then rmdir()
|
||||||
-- will fail (on Windows).
|
-- will fail (on Windows).
|
||||||
if not ret then -- Try again.
|
if not ret then -- Try again.
|
||||||
|
Loading…
Reference in New Issue
Block a user