mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 15:14:04 +00:00
refactor: fix luals warnings
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
local shared = vim
|
||||
local assert = require('luassert')
|
||||
local luaassert = require('luassert')
|
||||
local busted = require('busted')
|
||||
local luv = require('luv')
|
||||
local Paths = require('test.cmakeconfig.paths')
|
||||
|
||||
assert:set_parameter('TableFormatLevel', 100)
|
||||
luaassert:set_parameter('TableFormatLevel', 100)
|
||||
|
||||
local quote_me = '[^.%w%+%-%@%_%/]' -- complement (needn't quote)
|
||||
local function shell_quote(str)
|
||||
@@ -82,8 +82,8 @@ end
|
||||
-- Calls fn() until it succeeds, up to `max` times or until `max_ms`
|
||||
-- milliseconds have passed.
|
||||
function module.retry(max, max_ms, fn)
|
||||
assert(max == nil or max > 0)
|
||||
assert(max_ms == nil or max_ms > 0)
|
||||
luaassert(max == nil or max > 0)
|
||||
luaassert(max_ms == nil or max_ms > 0)
|
||||
local tries = 1
|
||||
local timeout = (max_ms and max_ms or 10000)
|
||||
local start_time = luv.now()
|
||||
@@ -108,10 +108,10 @@ local check_logs_useless_lines = {
|
||||
}
|
||||
|
||||
function module.eq(expected, actual, context)
|
||||
return assert.are.same(expected, actual, context)
|
||||
return luaassert.are.same(expected, actual, context)
|
||||
end
|
||||
function module.neq(expected, actual, context)
|
||||
return assert.are_not.same(expected, actual, context)
|
||||
return luaassert.are_not.same(expected, actual, context)
|
||||
end
|
||||
|
||||
--- Asserts that `cond` is true, or prints a message.
|
||||
@@ -120,21 +120,21 @@ end
|
||||
--- @param expected (any) description of expected result
|
||||
--- @param actual (any) description of actual result
|
||||
function module.ok(cond, expected, actual)
|
||||
assert(
|
||||
luaassert(
|
||||
(not expected and not actual) or (expected and actual),
|
||||
'if "expected" is given, "actual" is also required'
|
||||
)
|
||||
local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil
|
||||
return assert(cond, msg)
|
||||
return luaassert(cond, msg)
|
||||
end
|
||||
|
||||
local function epicfail(state, arguments, _)
|
||||
state.failure_message = arguments[1]
|
||||
return false
|
||||
end
|
||||
assert:register('assertion', 'epicfail', epicfail)
|
||||
luaassert:register('assertion', 'epicfail', epicfail)
|
||||
function module.fail(msg)
|
||||
return assert.epicfail(msg)
|
||||
return luaassert.epicfail(msg)
|
||||
end
|
||||
|
||||
function module.matches(pat, actual)
|
||||
@@ -154,7 +154,7 @@ end
|
||||
---@param inverse? (boolean) Assert that the pattern does NOT match.
|
||||
function module.assert_log(pat, logfile, nrlines, inverse)
|
||||
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
|
||||
assert(logfile ~= nil, 'no logfile')
|
||||
luaassert(logfile ~= nil, 'no logfile')
|
||||
nrlines = nrlines or 10
|
||||
inverse = inverse or false
|
||||
|
||||
@@ -191,7 +191,7 @@ function module.assert_nolog(pat, logfile, nrlines)
|
||||
end
|
||||
|
||||
function module.pcall(fn, ...)
|
||||
assert(type(fn) == 'function')
|
||||
luaassert(type(fn) == 'function')
|
||||
local status, rv = pcall(fn, ...)
|
||||
if status then
|
||||
return status, rv
|
||||
@@ -238,7 +238,7 @@ end
|
||||
-- matches('e[or]+$', pcall_err(function(a, b) error('some error') end, 'arg1', 'arg2'))
|
||||
--
|
||||
function module.pcall_err_withfile(fn, ...)
|
||||
assert(type(fn) == 'function')
|
||||
luaassert(type(fn) == 'function')
|
||||
local status, rv = module.pcall(fn, ...)
|
||||
if status == true then
|
||||
error('expected failure, but got success')
|
||||
@@ -315,7 +315,7 @@ function module.check_logs()
|
||||
for tail in vim.fs.dir(log_dir) do
|
||||
if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then
|
||||
local file = log_dir .. '/' .. tail
|
||||
local fd = io.open(file)
|
||||
local fd = assert(io.open(file))
|
||||
local start_msg = ('='):rep(20) .. ' File ' .. file .. ' ' .. ('='):rep(20)
|
||||
local lines = {}
|
||||
local warning_line = 0
|
||||
@@ -350,7 +350,7 @@ function module.check_logs()
|
||||
end
|
||||
end
|
||||
end
|
||||
assert(
|
||||
luaassert(
|
||||
0 == #runtime_errors,
|
||||
string.format('Found runtime errors in logfile(s): %s', table.concat(runtime_errors, ', '))
|
||||
)
|
||||
@@ -757,7 +757,7 @@ function module.format_luav(v, indent, opts)
|
||||
else
|
||||
print(type(v))
|
||||
-- Not implemented yet
|
||||
assert(false)
|
||||
luaassert(false)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -805,7 +805,7 @@ end
|
||||
|
||||
local fixtbl_metatable = {
|
||||
__newindex = function()
|
||||
assert(false)
|
||||
luaassert(false)
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ end
|
||||
|
||||
-- Dedent the given text and write it to the file name.
|
||||
function module.write_file(name, text, no_dedent, append)
|
||||
local file = io.open(name, (append and 'a' or 'w'))
|
||||
local file = assert(io.open(name, (append and 'a' or 'w')))
|
||||
if type(text) == 'table' then
|
||||
-- Byte blob
|
||||
local bytes = text
|
||||
@@ -920,7 +920,7 @@ end
|
||||
|
||||
function module.is_ci(name)
|
||||
local any = (name == nil)
|
||||
assert(any or name == 'github' or name == 'cirrus')
|
||||
luaassert(any or name == 'github' or name == 'cirrus')
|
||||
local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS'))
|
||||
local cirrus = ((any or name == 'cirrus') and nil ~= os.getenv('CIRRUS_CI'))
|
||||
return gh or cirrus
|
||||
|
||||
Reference in New Issue
Block a user