mirror of
https://github.com/neovim/neovim.git
synced 2026-01-07 03:48:02 +10:00
refactor(tests): merge n.spawn/n.spawn_argv into n.new_session #31859
Problem:
- `n.spawn()` is misleading because it also connects RPC, it's not just
"spawning" a process.
- It's confusing that `n.spawn()` and `n.spawn_argv()` are separate.
Solution:
- Replace `n.spawn()`/`n.spawn_argv()` with a single function `n.new_session()`.
This name aligns with the existing functions `n.set_session`/`n.get_session`.
- Note: removes direct handling of `prepend_argv`, but I doubt that was
important or intentional. If callers want to control use of `prepend_argv`
then we should add a new flag to `test.session.Opts`.
- Move `keep` to first parameter of `n.new_session()`.
- Add a `merge` flag to `test.session.Opts`
- Mark `_new_argv()` as private. Test should use clear/new_session/spawn_wait
instead.
This commit is contained in:
@@ -5,7 +5,6 @@ local clear, eq, eval, next_msg, ok, source = n.clear, t.eq, n.eval, n.next_msg,
|
||||
local command, fn, api = n.command, n.fn, n.api
|
||||
local matches = t.matches
|
||||
local sleep = vim.uv.sleep
|
||||
local spawn, nvim_argv = n.spawn, n.nvim_argv
|
||||
local get_session, set_session = n.get_session, n.set_session
|
||||
local nvim_prog = n.nvim_prog
|
||||
local is_os = t.is_os
|
||||
@@ -33,10 +32,10 @@ describe('channels', function()
|
||||
end)
|
||||
|
||||
pending('can connect to socket', function()
|
||||
local server = spawn(nvim_argv, nil, nil, true)
|
||||
local server = n.new_session(true)
|
||||
set_session(server)
|
||||
local address = fn.serverlist()[1]
|
||||
local client = spawn(nvim_argv, nil, nil, true)
|
||||
local client = n.new_session(true)
|
||||
set_session(client)
|
||||
source(init)
|
||||
|
||||
@@ -63,7 +62,7 @@ describe('channels', function()
|
||||
|
||||
it('dont crash due to garbage in rpc #23781', function()
|
||||
local client = get_session()
|
||||
local server = spawn(nvim_argv, nil, nil, true)
|
||||
local server = n.new_session(true)
|
||||
set_session(server)
|
||||
local address = fn.serverlist()[1]
|
||||
set_session(client)
|
||||
|
||||
Reference in New Issue
Block a user