mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Remove dependency on ffi module
This commit is contained in:
parent
bd81239f2f
commit
35d8d10a6a
@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
|
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
|
||||||
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
|
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
|
||||||
local os_is_windows = helpers.os_is_windows
|
local os_name = helpers.os_name
|
||||||
|
|
||||||
describe('vim_* functions', function()
|
describe('vim_* functions', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
@ -17,7 +17,7 @@ describe('vim_* functions', function()
|
|||||||
nvim('command', 'w')
|
nvim('command', 'w')
|
||||||
local f = io.open(fname)
|
local f = io.open(fname)
|
||||||
ok(f ~= nil)
|
ok(f ~= nil)
|
||||||
if os_is_windows() then
|
if os_name() == 'windows' then
|
||||||
eq('testing\r\napi\r\n', f:read('*a'))
|
eq('testing\r\napi\r\n', f:read('*a'))
|
||||||
else
|
else
|
||||||
eq('testing\napi\n', f:read('*a'))
|
eq('testing\napi\n', f:read('*a'))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require('coxpcall')
|
require('coxpcall')
|
||||||
local ffi = require('ffi')
|
|
||||||
local lfs = require('lfs')
|
local lfs = require('lfs')
|
||||||
local assert = require('luassert')
|
local assert = require('luassert')
|
||||||
local Loop = require('nvim.loop')
|
local Loop = require('nvim.loop')
|
||||||
@ -133,6 +132,22 @@ local function nvim_eval(expr)
|
|||||||
return request('vim_eval', expr)
|
return request('vim_eval', expr)
|
||||||
end
|
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, ...)
|
local function nvim_call(name, ...)
|
||||||
return request('vim_call_function', name, {...})
|
return request('vim_call_function', name, {...})
|
||||||
end
|
end
|
||||||
@ -247,7 +262,7 @@ end
|
|||||||
|
|
||||||
local function source(code)
|
local function source(code)
|
||||||
local tmpname = os.tmpname()
|
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
|
tmpname = '/private'..tmpname
|
||||||
end
|
end
|
||||||
write_file(tmpname, code)
|
write_file(tmpname, code)
|
||||||
@ -328,10 +343,6 @@ local function expect(contents)
|
|||||||
return eq(dedent(contents), curbuf_contents())
|
return eq(dedent(contents), curbuf_contents())
|
||||||
end
|
end
|
||||||
|
|
||||||
local function os_is_windows()
|
|
||||||
return nvim_eval('has("win32")') == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local function rmdir(path)
|
local function rmdir(path)
|
||||||
if lfs.attributes(path, 'mode') ~= 'directory' then
|
if lfs.attributes(path, 'mode') ~= 'directory' then
|
||||||
return nil
|
return nil
|
||||||
@ -434,7 +445,7 @@ return {
|
|||||||
wait = wait,
|
wait = wait,
|
||||||
set_session = set_session,
|
set_session = set_session,
|
||||||
write_file = write_file,
|
write_file = write_file,
|
||||||
os_is_windows = os_is_windows,
|
os_name = os_name,
|
||||||
rmdir = rmdir,
|
rmdir = rmdir,
|
||||||
mkdir = lfs.mkdir,
|
mkdir = lfs.mkdir,
|
||||||
exc_exec = exc_exec,
|
exc_exec = exc_exec,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
-- Test character classes in regexp using regexpengine 0, 1, 2.
|
-- Test character classes in regexp using regexpengine 0, 1, 2.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local ffi = require('ffi')
|
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
local source, write_file = helpers.source, helpers.write_file
|
local source, write_file = helpers.source, helpers.write_file
|
||||||
|
local os_name = helpers.os_name
|
||||||
|
|
||||||
local function sixlines(text)
|
local function sixlines(text)
|
||||||
local result = ''
|
local result = ''
|
||||||
@ -15,7 +15,7 @@ end
|
|||||||
|
|
||||||
local function diff(text, nodedent)
|
local function diff(text, nodedent)
|
||||||
local tmpname = os.tmpname()
|
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
|
tmpname = '/private'..tmpname
|
||||||
end
|
end
|
||||||
execute('w! '..tmpname)
|
execute('w! '..tmpname)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
-- Modules loaded here will not be cleared and reloaded by Busted.
|
-- Modules loaded here will not be cleared and reloaded by Busted.
|
||||||
-- Busted started doing this to help provide more isolation. See issue #62
|
-- Busted started doing this to help provide more isolation. See issue #62
|
||||||
-- for more information about this.
|
-- for more information about this.
|
||||||
local ffi = require('ffi')
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local nvim, eq, neq, eval = helpers.nvim, helpers.eq, helpers.neq, helpers.eval
|
local nvim, eq, neq, eval = helpers.nvim, helpers.eq, helpers.neq, helpers.eval
|
||||||
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
|
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
|
||||||
local os_is_windows = helpers.os_is_windows
|
local os_name = helpers.os_name
|
||||||
|
|
||||||
describe('serverstart(), serverstop()', function()
|
describe('serverstart(), serverstop()', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
@ -39,7 +39,7 @@ describe('serverstart(), serverstop()', function()
|
|||||||
eq('', meths.get_vvar('servername'))
|
eq('', meths.get_vvar('servername'))
|
||||||
|
|
||||||
-- v:servername will take the next available server.
|
-- v:servername will take the next available server.
|
||||||
local servername = (os_is_windows()
|
local servername = (os_name() == 'windows'
|
||||||
and [[\\.\pipe\Xtest-functional-server-server-pipe]]
|
and [[\\.\pipe\Xtest-functional-server-server-pipe]]
|
||||||
or 'Xtest-functional-server-server-socket')
|
or 'Xtest-functional-server-server-socket')
|
||||||
funcs.serverstart(servername)
|
funcs.serverstart(servername)
|
||||||
|
Loading…
Reference in New Issue
Block a user