mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
unittests: Fix linter errors
This commit is contained in:
parent
a54be846cf
commit
8ef6cfa6ac
@ -19,8 +19,13 @@ local api = cimport('./src/nvim/api/private/defs.h',
|
||||
|
||||
local obj2lua
|
||||
|
||||
obj2lua = function(obj)
|
||||
local obj2lua_tab = {
|
||||
local obj2lua_tab = nil
|
||||
|
||||
local function init_obj2lua_tab()
|
||||
if obj2lua_tab then
|
||||
return
|
||||
end
|
||||
obj2lua_tab = {
|
||||
[tonumber(api.kObjectTypeArray)] = function(obj)
|
||||
local ret = {[type_key]=list_type}
|
||||
for i = 1,tonumber(obj.data.array.size) do
|
||||
@ -59,6 +64,10 @@ obj2lua = function(obj)
|
||||
return ffi.string(obj.data.string.data, obj.data.string.size)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
obj2lua = function(obj)
|
||||
init_obj2lua_tab()
|
||||
return ((obj2lua_tab[tonumber(obj['type'])] or function(obj_inner)
|
||||
assert(false, 'Converting ' .. tostring(tonumber(obj_inner['type'])) .. ' is not implementing yet')
|
||||
end)(obj))
|
||||
|
@ -72,6 +72,7 @@ describe('json_decode_string()', function()
|
||||
end
|
||||
|
||||
itp('does not overflow in error messages', function()
|
||||
local saved_p_enc = decode.p_enc
|
||||
check_failure(']test', 1, 'E474: No container to close: ]')
|
||||
check_failure('[}test', 2, 'E474: Closing list with curly bracket: }')
|
||||
check_failure('{]test', 2,
|
||||
|
@ -11,7 +11,6 @@ local posix = nil
|
||||
local syscall = nil
|
||||
|
||||
local check_cores = global_helpers.check_cores
|
||||
local which = global_helpers.which
|
||||
local neq = global_helpers.neq
|
||||
local map = global_helpers.map
|
||||
local eq = global_helpers.eq
|
||||
@ -30,11 +29,11 @@ for _, p in ipairs(Paths.include_paths) do
|
||||
Preprocess.add_to_include_path(p)
|
||||
end
|
||||
|
||||
local pid = nil
|
||||
local child_pid = nil
|
||||
local function only_separate(func)
|
||||
return function(...)
|
||||
if pid ~= 0 then
|
||||
eq(0, 'This function must be run in a separate process only')
|
||||
if child_pid ~= 0 then
|
||||
error('This function must be run in a separate process only')
|
||||
end
|
||||
return func(...)
|
||||
end
|
||||
@ -44,7 +43,7 @@ local deferred_calls_mod = nil
|
||||
local function deferred_call(func, ret)
|
||||
return function(...)
|
||||
local deferred_calls = deferred_calls_mod or deferred_calls_init
|
||||
if pid ~= 0 then
|
||||
if child_pid ~= 0 then
|
||||
deferred_calls[#deferred_calls + 1] = {func=func, args={...}}
|
||||
return ret
|
||||
else
|
||||
@ -57,7 +56,7 @@ local separate_cleanups_mod = nil
|
||||
local function separate_cleanup(func)
|
||||
return function(...)
|
||||
local separate_cleanups = separate_cleanups_mod
|
||||
if pid ~= 0 then
|
||||
if child_pid ~= 0 then
|
||||
separate_cleanups[#separate_cleanups + 1] = {args={...}}
|
||||
else
|
||||
func(...)
|
||||
@ -68,10 +67,10 @@ end
|
||||
local libnvim = nil
|
||||
|
||||
local lib = setmetatable({}, {
|
||||
__index = only_separate(function(tbl, idx)
|
||||
__index = only_separate(function(_, idx)
|
||||
return libnvim[idx]
|
||||
end),
|
||||
__newindex = deferred_call(function(tbl, idx, val)
|
||||
__newindex = deferred_call(function(_, idx, val)
|
||||
libnvim[idx] = val
|
||||
end),
|
||||
})
|
||||
@ -154,10 +153,8 @@ cimport = function(...)
|
||||
or path:sub(2, 2) == ':') then
|
||||
path = './' .. path
|
||||
end
|
||||
local body
|
||||
if preprocess_cache[path] then
|
||||
body = preprocess_cache[path]
|
||||
else
|
||||
if not preprocess_cache[path] then
|
||||
local body
|
||||
body, previous_defines = Preprocess.preprocess(previous_defines, path)
|
||||
-- format it (so that the lines are "unique" statements), also filter out
|
||||
-- Objective-C blocks
|
||||
@ -178,10 +175,10 @@ cimport = function(...)
|
||||
end
|
||||
|
||||
local cimport_immediate = function(...)
|
||||
local saved_pid = pid
|
||||
pid = 0
|
||||
local saved_pid = child_pid
|
||||
child_pid = 0
|
||||
local err, emsg = pcall(cimport, ...)
|
||||
pid = saved_pid
|
||||
child_pid = saved_pid
|
||||
if not err then
|
||||
emsg = tostring(emsg)
|
||||
io.stderr:write(emsg .. '\n')
|
||||
@ -461,7 +458,7 @@ end
|
||||
|
||||
local function gen_itp(it)
|
||||
deferred_calls_mod = {}
|
||||
deferred_cleanups_mod = {}
|
||||
separate_cleanups_mod = {}
|
||||
preprocess_cache_mod = map(function(v) return v end, preprocess_cache_init)
|
||||
previous_defines_mod = previous_defines_init
|
||||
local function just_fail(_)
|
||||
@ -479,8 +476,8 @@ local function gen_itp(it)
|
||||
end
|
||||
it(name, function()
|
||||
local rd, wr = sc.pipe()
|
||||
pid = sc.fork()
|
||||
if pid == 0 then
|
||||
child_pid = sc.fork()
|
||||
if child_pid == 0 then
|
||||
init()
|
||||
sc.close(rd)
|
||||
collectgarbage('stop')
|
||||
@ -500,8 +497,8 @@ local function gen_itp(it)
|
||||
end
|
||||
else
|
||||
sc.close(wr)
|
||||
sc.wait(pid)
|
||||
pid = nil
|
||||
sc.wait(child_pid)
|
||||
child_pid = nil
|
||||
local function check()
|
||||
local res = sc.read(rd, 2)
|
||||
eq(2, #res)
|
||||
|
@ -11,7 +11,6 @@ local ffi, eq = helpers.ffi, helpers.eq
|
||||
local intern = helpers.internalize
|
||||
local to_cstr = helpers.to_cstr
|
||||
local NULL = ffi.cast('void *', 0)
|
||||
local deferred_call = deferred_call
|
||||
|
||||
describe('shell functions', function()
|
||||
before_each(function()
|
||||
|
Loading…
Reference in New Issue
Block a user