diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2025-01-04 06:29:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-04 06:29:13 -0800 |
commit | 975c2124a6e057e3f50ca5b2ad56572a39c633d9 (patch) | |
tree | e4fe80b5d9625c785a40aa66173808dcc2fe2941 /test/functional/options/defaults_spec.lua | |
parent | 7ddadd0feec663fcd9af1f30f055018a872cf2ba (diff) | |
download | rneovim-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/options/defaults_spec.lua')
-rw-r--r-- | test/functional/options/defaults_spec.lua | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index e7f47ef4e9..a82279e775 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -14,7 +14,6 @@ local api = n.api local command = n.command local clear = n.clear local exc_exec = n.exc_exec -local exec_lua = n.exec_lua local eval = n.eval local eq = t.eq local ok = t.ok @@ -929,17 +928,12 @@ describe('stdpath()', function() assert_alive() -- Check for crash. #8393 -- Check that Nvim rejects invalid APPNAMEs - -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness. local function test_appname(testAppname, expected_exitcode) - local lua_code = string.format( - [[ - local child = vim.fn.jobstart({ vim.v.progpath, '--clean', '--headless', '--listen', 'x', '+qall!' }, { env = { NVIM_APPNAME = %q } }) - return vim.fn.jobwait({ child }, %d)[1] - ]], - testAppname, - 3000 - ) - eq(expected_exitcode, exec_lua(lua_code)) + local p = n.spawn_wait({ + args = { '--listen', 'x', '+qall!' }, + env = { NVIM_APPNAME = testAppname }, + }) + eq(expected_exitcode, p.status) end -- Invalid appnames: test_appname('a/../b', 1) |