diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-09-18 23:43:32 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-09-20 11:08:14 +0200 |
commit | 764f576d641fbc1f0608148d995a63847adb010e (patch) | |
tree | b6afb1b05e0372d0ac01b69c0badda14323a91d0 /test/functional/helpers.lua | |
parent | efe8311371830930b2ab14937b8d6adc801cc99b (diff) | |
download | rneovim-764f576d641fbc1f0608148d995a63847adb010e.tar.gz rneovim-764f576d641fbc1f0608148d995a63847adb010e.tar.bz2 rneovim-764f576d641fbc1f0608148d995a63847adb010e.zip |
test/helpers.rmdir(): Retry once after a delay.
Attempt to avoid "Permission denied" on Windows potentially caused by open
filepath handle in sibling process.
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index f6d09e6139..0fb168b736 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -376,8 +376,8 @@ local function wait() end -- sleeps the test runner (_not_ the nvim instance) -local function sleep(timeout) - run(nil, nil, nil, timeout) +local function sleep(ms) + run(nil, nil, nil, ms) end local function curbuf_contents() @@ -403,7 +403,7 @@ local function expect(contents) return eq(dedent(contents), curbuf_contents()) end -local function rmdir(path) +local function do_rmdir(path) if lfs.attributes(path, 'mode') ~= 'directory' then return nil end @@ -411,7 +411,7 @@ local function rmdir(path) if file ~= '.' and file ~= '..' then local abspath = path..'/'..file if lfs.attributes(abspath, 'mode') == 'directory' then - local ret = rmdir(abspath) -- recurse + local ret = do_rmdir(abspath) -- recurse if not ret then return nil end @@ -431,6 +431,16 @@ local function rmdir(path) return ret end +local function rmdir(path) + local ret, err = pcall(do_rmdir, path) + -- During teardown, the nvim process may not exit quickly enough, then rmdir() + -- will fail (on Windows). + if not ret then -- Try again. + sleep(1000) + do_rmdir(path) + end +end + local exc_exec = function(cmd) nvim_command(([[ try |