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/core/startup_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/core/startup_spec.lua')
-rw-r--r-- | test/functional/core/startup_spec.lua | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index c9ea280646..642e2b0287 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -77,22 +77,9 @@ describe('startup', function() end) it('--startuptime does not crash on error #31125', function() - eq( - "E484: Can't open file .", - fn.system({ - nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - '--headless', - '--startuptime', - '.', - '-c', - '42cquit', - }) - ) - eq(42, api.nvim_get_vvar('shell_error')) + local p = n.spawn_wait('--startuptime', '.', '-c', '42cquit') + eq("E484: Can't open file .", p.stderr) + eq(42, p.status) end) it('-D does not hang #12647', function() @@ -184,7 +171,7 @@ describe('startup', function() it('Lua-error sets Nvim exitcode', function() local proc = n.spawn_wait('-l', 'test/functional/fixtures/startup-fail.lua') - matches('E5113: .* my pearls!!', proc.output) + matches('E5113: .* my pearls!!', proc:output()) eq(1, proc.status) eq(0, eval('v:shell_error')) @@ -606,15 +593,15 @@ describe('startup', function() it('fails on --embed with -es/-Es/-l', function() matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-es' }) + n.spawn_wait('--embed', '-es').stderr ) matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-Es' }) + n.spawn_wait('--embed', '-Es').stderr ) matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-l', 'foo.lua' }) + n.spawn_wait('--embed', '-l', 'foo.lua').stderr ) end) @@ -698,20 +685,8 @@ describe('startup', function() end) it('get command line arguments from v:argv', function() - local out = fn.system({ - nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - '--headless', - '--cmd', - nvim_set, - '-c', - [[echo v:argv[-1:] len(v:argv) > 1]], - '+q', - }) - eq("['+q'] 1", out) + local p = n.spawn_wait('--cmd', nvim_set, '-c', [[echo v:argv[-1:] len(v:argv) > 1]], '+q') + eq("['+q'] 1", p.stderr) end) end) |