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

@@ -106,20 +106,15 @@ describe('vim.ui_attach', function()
end)
it('does not crash on exit', function()
fn.system({
n.nvim_prog,
'-u',
'NONE',
'-i',
'NONE',
local p = n.spawn_wait(
'--cmd',
[[ lua ns = vim.api.nvim_create_namespace 'testspace' ]],
'--cmd',
[[ lua vim.ui_attach(ns, {ext_popupmenu=true}, function() end) ]],
'--cmd',
'quitall!',
})
eq(0, n.eval('v:shell_error'))
'quitall!'
)
eq(0, p.status)
end)
it('can receive accurate message kinds even if they are history', function()