commit dbe07e292ea3f56cfc5ca322ce53b7edae39f20a
parent 16495e686371d45f02eafff5aa3216ca15d5f735
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Mon, 16 Feb 2026 19:19:58 -0500
refactor(tests): server_spec #37912
Diffstat:
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/test/functional/core/server_spec.lua b/test/functional/core/server_spec.lua
@@ -270,28 +270,24 @@ end)
describe('startup --listen', function()
-- Tests Nvim output when failing to start, with and without "--headless".
- -- TODO(justinmk): clear() should have a way to get stdout if Nvim fails to start.
local function _test(args, env, expected)
local function run(cmd)
- return n.exec_lua(function(cmd_, env_)
- return vim
- .system(cmd_, {
- text = true,
- env = vim.tbl_extend(
- 'force',
- -- Avoid noise in the logs; we expect failures for these tests.
- { NVIM_LOG_FILE = testlog },
- env_ or {}
- ),
- })
- :wait()
- end, cmd, env) --[[@as vim.SystemCompleted]]
+ return n.spawn_wait {
+ merge = false,
+ args = cmd,
+ env = vim.tbl_extend(
+ 'force',
+ -- Avoid noise in the logs; we expect failures for these tests.
+ { NVIM_LOG_FILE = testlog },
+ env or {}
+ ),
+ }
end
- local cmd = vim.list_extend({ n.nvim_prog, '+qall!', '--headless' }, args)
+ local cmd = vim.list_extend({ '--clean', '+qall!', '--headless' }, args)
local r = run(cmd)
- eq(1, r.code)
- matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
+ eq(1, r.status)
+ matches(expected, r:output():gsub('\\n', ' '))
if is_os('win') then
return -- On Windows, output without --headless is garbage.
@@ -299,8 +295,8 @@ describe('startup --listen', function()
table.remove(cmd, 3) -- Remove '--headless'.
assert(not vim.tbl_contains(cmd, '--headless'))
r = run(cmd)
- eq(1, r.code)
- matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
+ eq(1, r.status)
+ matches(expected, r:output():gsub('\\n', ' '))
end
it('validates', function()
diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua
@@ -458,7 +458,9 @@ end
--- Starts a new, global Nvim session and clears the current one.
---
---- Note: Use `new_session()` to start a session without replacing the current one.
+--- Note:
+--- - Use `new_session()` to start a session without replacing the current one.
+--- - Use `spawn_wait()` to start Nvim without connecting a RPC session.
---
--- Parameters are interpreted as startup args, OR a map with these keys:
--- - args: List: Args appended to the default `nvim_argv` set.
@@ -488,7 +490,7 @@ local n_processes = 0
--- Does not replace the current global session, unlike `clear()`.
---
--- @param keep boolean (default: false) Don't close the current global session.
---- @param ... string Nvim CLI args (or see overload)
+--- @param ... string Nvim CLI args
--- @return test.Session
--- @overload fun(keep: boolean, opts: test.session.Opts): test.Session
function M.new_session(keep, ...)