aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-07-20 18:21:29 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-07-20 18:21:29 -0400
commit0e39b2c93637af3e79bc29b97cffde5b9cd7cd2e (patch)
treeb9e34ca2c4d8bd196903f1e3ae875b2acc89e940
parent05bb841487dd085eb2140e18c5aa8a8b098244da (diff)
parent2b2cea38a9822c7f8ac88f33099252bd0378b9ba (diff)
downloadrneovim-0e39b2c93637af3e79bc29b97cffde5b9cd7cd2e.tar.gz
rneovim-0e39b2c93637af3e79bc29b97cffde5b9cd7cd2e.tar.bz2
rneovim-0e39b2c93637af3e79bc29b97cffde5b9cd7cd2e.zip
Merge #3056 'Test: fix functional/ex_cmds/recover_spec.lua'.
-rw-r--r--test/functional/ex_cmds/recover_spec.lua4
-rw-r--r--test/functional/helpers.lua25
2 files changed, 26 insertions, 3 deletions
diff --git a/test/functional/ex_cmds/recover_spec.lua b/test/functional/ex_cmds/recover_spec.lua
index d4c9477133..b92739e40e 100644
--- a/test/functional/ex_cmds/recover_spec.lua
+++ b/test/functional/ex_cmds/recover_spec.lua
@@ -20,11 +20,11 @@ describe(':preserve', function()
local swapdir = lfs.currentdir()..'/testdir_recover_spec'
before_each(function()
clear()
- os.remove(swapdir)
+ helpers.rmdir(swapdir)
lfs.mkdir(swapdir)
end)
after_each(function()
- os.remove(swapdir)
+ helpers.rmdir(swapdir)
end)
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 33d04616a0..d5c22c6f1c 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -290,6 +290,28 @@ local function expect(contents)
return eq(dedent(contents), curbuf_contents())
end
+local function rmdir(path)
+ if lfs.attributes(path, 'mode') ~= 'directory' then
+ return nil
+ end
+ for file in lfs.dir(path) do
+ if file == '.' or file == '..' then
+ goto continue
+ end
+ ret, err = os.remove(path..'/'..file)
+ if not ret then
+ error('os.remove: '..err)
+ return nil
+ end
+ ::continue::
+ end
+ ret, err = os.remove(path)
+ if not ret then
+ error('os.remove: '..err)
+ end
+ return ret
+end
+
return {
clear = clear,
spawn = spawn,
@@ -321,5 +343,6 @@ return {
curbuf_contents = curbuf_contents,
wait = wait,
set_session = set_session,
- write_file = write_file
+ write_file = write_file,
+ rmdir = rmdir
}