aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-04 06:35:21 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-01-04 07:23:13 +0100
commita63675c38426944001139b5eaf36d1eb7963df2f (patch)
tree48bf7c189ba8efc4ba5fb6e50d078993bec9f08e /test/functional/helpers.lua
parente43f7425ee3db238e3b38399307b8aefedfaacf2 (diff)
downloadrneovim-a63675c38426944001139b5eaf36d1eb7963df2f.tar.gz
rneovim-a63675c38426944001139b5eaf36d1eb7963df2f.tar.bz2
rneovim-a63675c38426944001139b5eaf36d1eb7963df2f.zip
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.
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index f3332cff4f..86fca401ac 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -14,6 +14,7 @@ local neq = global_helpers.neq
local eq = global_helpers.eq
local ok = global_helpers.ok
+local start_dir = lfs.currentdir()
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.',
@@ -475,6 +476,12 @@ end
local function 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()
-- will fail (on Windows).
if not ret then -- Try again.