test: fix some type warnings (#37483)

This commit is contained in:
zeertzjq
2026-01-21 15:11:47 +08:00
committed by GitHub
parent c556972ae1
commit 1883fe39bd
8 changed files with 19 additions and 15 deletions

View File

@@ -149,9 +149,9 @@ ProcStream.__index = ProcStream
--- @param argv string[]
--- @param env string[]?
--- @param io_extra uv.uv_pipe_t?
--- @param on_exit fun(closed: integer?)? Called after the child process exits.
--- @param forward_stderr forward stderr from the nvim process. otherwise collect it.
--- @param on_exit fun(closed: integer?)? Called after the child process exits.
--- `closed` is the timestamp (uv.now()) when close() was called, or nil if it wasn't.
--- @param forward_stderr boolean? Forward child process stderr, otherwise collect it.
--- @return test.ProcStream
function ProcStream.spawn(argv, env, io_extra, on_exit, forward_stderr)
local self = setmetatable({

View File

@@ -1,6 +1,6 @@
local M = {}
M.include_paths = {}
M.include_paths = {} --- @type string[]
for p in ("${TEST_INCLUDE_DIRS}" .. ";"):gmatch("[^;]+") do
table.insert(M.include_paths, p)
end

View File

@@ -543,7 +543,7 @@ end
describe('TUI', function()
local screen --[[@type test.functional.ui.screen]]
local child_session --[[@type test.Session]]
local child_exec_lua
local child_exec_lua --[[@type fun(code: string, ...):any]]
before_each(function()
clear()
@@ -2987,8 +2987,8 @@ describe('TUI UIEnter/UILeave', function()
end)
describe('TUI FocusGained/FocusLost', function()
local screen
local child_session
local screen --[[@type test.functional.ui.screen]]
local child_session --[[@type test.Session]]
before_each(function()
clear()
@@ -3181,7 +3181,7 @@ end)
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe("TUI 't_Co' (terminal colors)", function()
local screen
local screen --[[@type test.functional.ui.screen]]
local function assert_term_colors(term, colorterm, maxcolors)
clear({ env = { TERM = term }, args = {} })
@@ -3199,7 +3199,7 @@ describe("TUI 't_Co' (terminal colors)", function()
},
})
local tline
local tline --[[@type string]]
if maxcolors == 8 then
tline = '{112:~ }'
elseif maxcolors == 16 then
@@ -3460,7 +3460,7 @@ end)
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe("TUI 'term' option", function()
local screen
local screen --[[@type test.functional.ui.screen]]
local function assert_term(term_envvar, term_expected)
clear()
@@ -3511,7 +3511,7 @@ end)
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe('TUI', function()
local screen
local screen --[[@type test.functional.ui.screen]]
-- Runs (child) `nvim` in a TTY (:terminal), to start the builtin TUI.
local function nvim_tui(extra_args)

View File

@@ -33,6 +33,8 @@ function M.feed_csi(data)
M.feed_termcode('[' .. data)
end
--- @param session test.Session
--- @return fun(code: string, ...):any
function M.make_lua_executor(session)
return function(code, ...)
local status, rv = session:request('nvim_exec_lua', code, { ... })

View File

@@ -447,6 +447,7 @@ end
--- @field mouse_enabled? boolean
---
--- @field win_viewport? table<integer,table<string,integer>>
--- @field win_viewport_margins? table<integer,table<string,integer>>
--- @field win_pos? table<integer,table<string,integer>>
--- @field float_pos? [integer,integer]
--- @field hl_groups? table<string,integer>

View File

@@ -49,7 +49,7 @@ function M.fix_slashes(obj)
end
--- @param ... string|string[]
--- @return string
--- @return string[]
function M.argss_to_cmd(...)
local cmd = {} --- @type string[]
for i = 1, select('#', ...) do

View File

@@ -163,8 +163,7 @@ end
--- @param hdr string
--- @return string[]?
function Gcc:dependencies(hdr)
--- @type string
local cmd = argss_to_cmd(self.path, { '-M', hdr }) .. ' 2>&1'
local cmd = table.concat(argss_to_cmd(self.path, { '-M', hdr }), ' ') .. ' 2>&1'
local out = assert(io.popen(cmd))
local deps = out:read('*a')
out:close()

View File

@@ -201,8 +201,10 @@ local function is_child_cdefs()
return os.getenv('NVIM_TEST_MAIN_CDEFS') ~= '1'
end
-- use this helper to import C files, you can pass multiple paths at once,
-- this helper will return the C namespace of the nvim library.
--- use this helper to import C files, you can pass multiple paths at once,
--- this helper will return the C namespace of the nvim library.
---
--- @param ... string
local function cimport(...)
local previous_defines --- @type string
local preprocess_cache --- @type table<string,string>