commit 1883fe39bdee47a246a913ba021237d1893aaa90
parent c556972ae10d0e61337dbc804a4a0af4e390f98e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 21 Jan 2026 15:11:47 +0800
test: fix some type warnings (#37483)
Diffstat:
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/test/client/uv_stream.lua b/test/client/uv_stream.lua
@@ -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({
diff --git a/test/cmakeconfig/paths.lua.in b/test/cmakeconfig/paths.lua.in
@@ -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
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
@@ -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)
diff --git a/test/functional/testterm.lua b/test/functional/testterm.lua
@@ -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, { ... })
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
@@ -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>
diff --git a/test/testutil.lua b/test/testutil.lua
@@ -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
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
@@ -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()
diff --git a/test/unit/testutil.lua b/test/unit/testutil.lua
@@ -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>