mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 13:08:33 +00:00
test(tui_spec): avoid dangling Nvim processes on test failure (#35900)
Also don't wait indefinitely for all Nvim processes to exit.
This commit is contained in:
@@ -3820,6 +3820,10 @@ describe('TUI client', function()
|
|||||||
it('connects to remote instance (with its own TUI)', function()
|
it('connects to remote instance (with its own TUI)', function()
|
||||||
local server_super = n.new_session(false)
|
local server_super = n.new_session(false)
|
||||||
local client_super = n.new_session(true)
|
local client_super = n.new_session(true)
|
||||||
|
finally(function()
|
||||||
|
server_super:close()
|
||||||
|
client_super:close()
|
||||||
|
end)
|
||||||
|
|
||||||
set_session(server_super)
|
set_session(server_super)
|
||||||
local server_pipe = new_pipename()
|
local server_pipe = new_pipename()
|
||||||
@@ -3894,14 +3898,15 @@ describe('TUI client', function()
|
|||||||
screen_client:expect({ any = 'GUI Running: 0' })
|
screen_client:expect({ any = 'GUI Running: 0' })
|
||||||
|
|
||||||
feed_data(':q!\n')
|
feed_data(':q!\n')
|
||||||
|
|
||||||
server_super:close()
|
|
||||||
client_super:close()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('connects to remote instance (--headless)', function()
|
it('connects to remote instance (--headless)', function()
|
||||||
local server = n.new_session(false)
|
local server = n.new_session(false)
|
||||||
local client_super = n.new_session(true, { env = { NVIM_LOG_FILE = testlog } })
|
local client_super = n.new_session(true, { env = { NVIM_LOG_FILE = testlog } })
|
||||||
|
finally(function()
|
||||||
|
client_super:close()
|
||||||
|
server:close()
|
||||||
|
end)
|
||||||
|
|
||||||
set_session(server)
|
set_session(server)
|
||||||
local server_pipe = api.nvim_get_vvar('servername')
|
local server_pipe = api.nvim_get_vvar('servername')
|
||||||
@@ -3971,8 +3976,6 @@ describe('TUI client', function()
|
|||||||
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
||||||
screen_client:expect({ any = 'GUI Running: 0' })
|
screen_client:expect({ any = 'GUI Running: 0' })
|
||||||
|
|
||||||
client_super:close()
|
|
||||||
server:close()
|
|
||||||
if is_os('mac') then
|
if is_os('mac') then
|
||||||
assert_log('uv_tty_set_mode failed: Unknown system error %-102', testlog)
|
assert_log('uv_tty_set_mode failed: Unknown system error %-102', testlog)
|
||||||
end
|
end
|
||||||
|
@@ -519,15 +519,26 @@ function M.new_session(keep, ...)
|
|||||||
n_processes = n_processes + 1
|
n_processes = n_processes + 1
|
||||||
|
|
||||||
local new_session = Session.new(proc)
|
local new_session = Session.new(proc)
|
||||||
|
-- Make it possible to check whether two sessions are from the same test.
|
||||||
new_session.data = { test_id = test_id }
|
new_session.data = { test_id = test_id }
|
||||||
return new_session
|
return new_session
|
||||||
end
|
end
|
||||||
|
|
||||||
busted.subscribe({ 'suite', 'end' }, function()
|
busted.subscribe({ 'suite', 'end' }, function()
|
||||||
M.check_close(true)
|
M.check_close(true)
|
||||||
while n_processes > 0 do
|
local timed_out = false
|
||||||
|
local timer = assert(vim.uv.new_timer())
|
||||||
|
timer:start(10000, 0, function()
|
||||||
|
timed_out = true
|
||||||
|
end)
|
||||||
|
while n_processes > 0 and not timed_out do
|
||||||
uv.run('once')
|
uv.run('once')
|
||||||
end
|
end
|
||||||
|
timer:close()
|
||||||
|
if timed_out then
|
||||||
|
print(('warning: %d dangling Nvim processes'):format(n_processes))
|
||||||
|
io.stdout:flush()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Starts a (non-RPC, `--headless --listen "Tx"`) Nvim process, waits for exit, and returns result.
|
--- Starts a (non-RPC, `--headless --listen "Tx"`) Nvim process, waits for exit, and returns result.
|
||||||
|
Reference in New Issue
Block a user