diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-09-20 12:32:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-20 12:32:42 +0200 |
commit | bba6315580814bcd2b2dea8340a4d47265854949 (patch) | |
tree | 6a5dc23a6291a95af4190e1950f6a5da60894a4a /test/functional/helpers.lua | |
parent | efe8311371830930b2ab14937b8d6adc801cc99b (diff) | |
parent | 911421d328a91a56389248fe27bee6c95784d95f (diff) | |
download | rneovim-bba6315580814bcd2b2dea8340a4d47265854949.tar.gz rneovim-bba6315580814bcd2b2dea8340a4d47265854949.tar.bz2 rneovim-bba6315580814bcd2b2dea8340a4d47265854949.zip |
Merge #5362 from justinmk/testcleanup
test: helpers.rmdir(): retry+sleep on failure
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index f6d09e6139..d5b7442b57 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 @@ -424,13 +424,23 @@ local function rmdir(path) end end end - local ret, err = os.remove(path) + local ret, err = lfs.rmdir(path) if not ret then - error('os.remove: '..err) + error('lfs.rmdir('..path..'): '..err) end return ret end +local function rmdir(path) + local ret, _ = 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 |