aboutsummaryrefslogtreecommitdiff
path: root/test/functional/testnvim.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-01-04 06:29:13 -0800
committerGitHub <noreply@github.com>2025-01-04 06:29:13 -0800
commit975c2124a6e057e3f50ca5b2ad56572a39c633d9 (patch)
treee4fe80b5d9625c785a40aa66173808dcc2fe2941 /test/functional/testnvim.lua
parent7ddadd0feec663fcd9af1f30f055018a872cf2ba (diff)
downloadrneovim-975c2124a6e057e3f50ca5b2ad56572a39c633d9.tar.gz
rneovim-975c2124a6e057e3f50ca5b2ad56572a39c633d9.tar.bz2
rneovim-975c2124a6e057e3f50ca5b2ad56572a39c633d9.zip
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.
Diffstat (limited to 'test/functional/testnvim.lua')
-rw-r--r--test/functional/testnvim.lua13
1 files changed, 2 insertions, 11 deletions
diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua
index c8f1c35555..aa66e07ad0 100644
--- a/test/functional/testnvim.lua
+++ b/test/functional/testnvim.lua
@@ -318,16 +318,6 @@ function M.stop()
assert(session):stop()
end
-function M.nvim_prog_abs()
- -- system(['build/bin/nvim']) does not work for whatever reason. It must
- -- be executable searched in $PATH or something starting with / or ./.
- if M.nvim_prog:match('[/\\]') then
- return M.request('nvim_call_function', 'fnamemodify', { M.nvim_prog, ':p' })
- else
- return M.nvim_prog
- end
-end
-
-- Use for commands which expect nvim to quit.
-- The first argument can also be a timeout.
function M.expect_exit(fn_or_timeout, ...)
@@ -526,7 +516,7 @@ function M.spawn_argv(keep, ...)
return M.spawn(argv, nil, env, keep, io_extra)
end
---- Starts a (`--headless`, non-RPC) Nvim process, waits for exit, and returns output + info.
+--- Starts a (non-RPC, `--headless --listen "Tx"`) Nvim process, waits for exit, and returns result.
---
--- @param ... string Nvim CLI args
--- @return test.ProcStream
@@ -537,6 +527,7 @@ function M.spawn_wait(...)
table.insert(opts.args_rm, '--embed')
local argv, env, io_extra = M.new_argv(opts)
local proc = ProcStream.spawn(argv, env, io_extra)
+ proc.collect_text = true
proc:read_start()
proc:wait()
proc:close()