test: use spawn_wait() instead of system() #31852

Problem:
Tests that need to check `nvim` CLI behavior (no RPC session) create
their own ad-hoc `system()` wrappers.

Solution:
- Use `n.spawn_wait` instead of `system()`.
- Bonus: this also improves the tests by explicitly checking for
  `stdout` or `stderr`. And if a signal is raised, `ProcStream.status`
  will reflect it.
This commit is contained in:
Justin M. Keyes
2025-01-04 06:29:13 -08:00
committed by GitHub
parent 7ddadd0fee
commit 975c2124a6
8 changed files with 78 additions and 146 deletions

View File

@@ -8,8 +8,6 @@ local feed = n.feed
local eval = n.eval
local eq = t.eq
local run = n.run
local fn = n.fn
local nvim_prog = n.nvim_prog
local pcall_err = t.pcall_err
local exec_capture = n.exec_capture
local poke_eventloop = n.poke_eventloop
@@ -69,8 +67,8 @@ describe(':cquit', function()
poke_eventloop()
assert_alive()
else
fn.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline })
eq(exit_code, eval('v:shell_error'))
local p = n.spawn_wait('--cmd', cmdline)
eq(exit_code, p.status)
end
end