aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2016-03-07 15:20:16 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2016-03-07 15:20:16 -0300
commit37b3a4c607a1305ce56e96837e305fd637fde0e8 (patch)
tree2b825e07c89d31557b4e6c6c6dcff029de6a5ded /test/functional/helpers.lua
parentbd81239f2f98e46f8565c7d80d586381881e78b4 (diff)
parent6674930d7c15e30b6110c4ff2489dd30985969e6 (diff)
downloadrneovim-37b3a4c607a1305ce56e96837e305fd637fde0e8.tar.gz
rneovim-37b3a4c607a1305ce56e96837e305fd637fde0e8.tar.bz2
rneovim-37b3a4c607a1305ce56e96837e305fd637fde0e8.zip
Merge PR #4423 'Make functional tests compatible with lua'
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua39
1 files changed, 24 insertions, 15 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 1fba15c2c3..55c97d451b 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -1,5 +1,4 @@
require('coxpcall')
-local ffi = require('ffi')
local lfs = require('lfs')
local assert = require('luassert')
local Loop = require('nvim.loop')
@@ -133,6 +132,22 @@ local function nvim_eval(expr)
return request('vim_eval', expr)
end
+local os_name = (function()
+ local name = nil
+ return (function()
+ if not name then
+ if nvim_eval('has("win32")') == 1 then
+ name = 'windows'
+ elseif nvim_eval('has("macunix")') == 1 then
+ name = 'osx'
+ else
+ name = 'unix'
+ end
+ end
+ return name
+ end)
+end)()
+
local function nvim_call(name, ...)
return request('vim_call_function', name, {...})
end
@@ -247,7 +262,7 @@ end
local function source(code)
local tmpname = os.tmpname()
- if ffi.os == 'OSX' and string.match(tmpname, '^/tmp') then
+ if os_name() == 'osx' and string.match(tmpname, '^/tmp') then
tmpname = '/private'..tmpname
end
write_file(tmpname, code)
@@ -328,24 +343,18 @@ local function expect(contents)
return eq(dedent(contents), curbuf_contents())
end
-local function os_is_windows()
- return nvim_eval('has("win32")') == 1
-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
- local ret, err = os.remove(path..'/'..file)
- if not ret then
- error('os.remove: '..err)
- return nil
+ if file ~= '.' and file ~= '..' then
+ local ret, err = os.remove(path..'/'..file)
+ if not ret then
+ error('os.remove: '..err)
+ return nil
+ end
end
- ::continue::
end
local ret, err = os.remove(path)
if not ret then
@@ -434,7 +443,7 @@ return {
wait = wait,
set_session = set_session,
write_file = write_file,
- os_is_windows = os_is_windows,
+ os_name = os_name,
rmdir = rmdir,
mkdir = lfs.mkdir,
exc_exec = exc_exec,