mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
test(tui_spec): deduplicate (#36003)
This commit is contained in:
@@ -3401,10 +3401,6 @@ end)
|
||||
-- does not initialize the TUI.
|
||||
describe('TUI', function()
|
||||
local screen
|
||||
local logfile = 'Xtest_tui_verbose_log'
|
||||
after_each(function()
|
||||
os.remove(logfile)
|
||||
end)
|
||||
|
||||
-- Runs (child) `nvim` in a TTY (:terminal), to start the builtin TUI.
|
||||
local function nvim_tui(extra_args)
|
||||
@@ -3424,7 +3420,11 @@ describe('TUI', function()
|
||||
end
|
||||
|
||||
it('-V3log logs terminfo values', function()
|
||||
local logfile = 'Xtest_tui_verbose_log'
|
||||
nvim_tui('-V3' .. logfile)
|
||||
finally(function()
|
||||
os.remove(logfile)
|
||||
end)
|
||||
|
||||
-- Wait for TUI to start.
|
||||
feed_data('Gitext')
|
||||
@@ -3436,7 +3436,7 @@ describe('TUI', function()
|
||||
]])
|
||||
|
||||
retry(nil, 3000, function() -- Wait for log file to be flushed.
|
||||
local log = read_file('Xtest_tui_verbose_log') or ''
|
||||
local log = read_file(logfile) or ''
|
||||
eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n')) -- }}}
|
||||
ok(#log > 50)
|
||||
end)
|
||||
@@ -3813,19 +3813,14 @@ describe('TUI bg color', function()
|
||||
end)
|
||||
|
||||
describe('TUI client', function()
|
||||
after_each(function()
|
||||
os.remove(testlog)
|
||||
end)
|
||||
|
||||
it('connects to remote instance (with its own TUI)', function()
|
||||
local server_super = n.new_session(false)
|
||||
local function start_tui_and_remote_client()
|
||||
local server_super = n.clear()
|
||||
local client_super = n.new_session(true)
|
||||
finally(function()
|
||||
server_super:close()
|
||||
client_super:close()
|
||||
end)
|
||||
|
||||
set_session(server_super)
|
||||
local server_pipe = new_pipename()
|
||||
local screen_server = tt.setup_child_nvim({
|
||||
'--clean',
|
||||
@@ -3836,6 +3831,13 @@ describe('TUI client', function()
|
||||
'--cmd',
|
||||
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
||||
})
|
||||
screen_server:expect([[
|
||||
^ |
|
||||
{100:~ }|*3
|
||||
{3:[No Name] }|
|
||||
|
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
feed_data('iHello, World')
|
||||
screen_server:expect([[
|
||||
@@ -3866,7 +3868,13 @@ describe('TUI client', function()
|
||||
})
|
||||
screen_client:expect(s0)
|
||||
|
||||
-- 3: should has("gui_running") be 1 when there is a remote TUI?
|
||||
return server_super, screen_server, screen_client
|
||||
end
|
||||
|
||||
it('connects to remote instance (with its own TUI)', function()
|
||||
local _, screen_server, screen_client = start_tui_and_remote_client()
|
||||
|
||||
-- XXX: should has("gui_running") be 1 when there is a remote TUI?
|
||||
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
||||
screen_client:expect({ any = 'GUI Running: 1' })
|
||||
|
||||
@@ -3900,15 +3908,17 @@ describe('TUI client', function()
|
||||
feed_data(':q!\n')
|
||||
end)
|
||||
|
||||
it('connects to remote instance (--headless)', function()
|
||||
local function start_headless_server_and_client()
|
||||
local server = n.new_session(false)
|
||||
local client_super = n.new_session(true, { env = { NVIM_LOG_FILE = testlog } })
|
||||
finally(function()
|
||||
client_super:close()
|
||||
server:close()
|
||||
os.remove(testlog)
|
||||
end)
|
||||
|
||||
set_session(server)
|
||||
--- @type string
|
||||
local server_pipe = api.nvim_get_vvar('servername')
|
||||
server:request('nvim_input', 'iHalloj!<Esc>')
|
||||
server:request('nvim_command', 'set notermguicolors')
|
||||
@@ -3919,7 +3929,6 @@ describe('TUI client', function()
|
||||
'--server',
|
||||
server_pipe,
|
||||
})
|
||||
|
||||
screen_client:expect([[
|
||||
Halloj^! |
|
||||
{100:~ }|*4
|
||||
@@ -3927,6 +3936,12 @@ describe('TUI client', function()
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
return server, server_pipe, screen_client
|
||||
end
|
||||
|
||||
it('connects to remote instance (--headless)', function()
|
||||
local server, server_pipe, screen_client = start_headless_server_and_client()
|
||||
|
||||
-- No heap-use-after-free when receiving UI events after deadly signal #22184
|
||||
server:request('nvim_input', ('a'):rep(1000))
|
||||
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
|
||||
@@ -3956,7 +3971,7 @@ describe('TUI client', function()
|
||||
]])
|
||||
feed_data('\027')
|
||||
|
||||
-- 3: should has("gui_running") be 1 when there is a remote TUI?
|
||||
-- XXX: should has("gui_running") be 1 when there is a remote TUI?
|
||||
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
||||
screen_client:expect({ any = 'GUI Running: 1' })
|
||||
|
||||
@@ -3999,62 +4014,7 @@ describe('TUI client', function()
|
||||
end)
|
||||
|
||||
local function test_remote_tui_quit(status)
|
||||
local server_super = n.clear()
|
||||
local client_super = n.new_session(true)
|
||||
finally(function()
|
||||
server_super:close()
|
||||
client_super:close()
|
||||
end)
|
||||
|
||||
local server_pipe = new_pipename()
|
||||
local screen_server = tt.setup_child_nvim({
|
||||
'--clean',
|
||||
'--listen',
|
||||
server_pipe,
|
||||
'--cmd',
|
||||
'colorscheme vim',
|
||||
'--cmd',
|
||||
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
||||
})
|
||||
screen_server:expect([[
|
||||
^ |
|
||||
{100:~ }|*3
|
||||
{3:[No Name] }|
|
||||
|
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
feed_data('iHello, World')
|
||||
screen_server:expect([[
|
||||
Hello, World^ |
|
||||
{100:~ }|*3
|
||||
{3:[No Name] [+] }|
|
||||
{5:-- INSERT --} |
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
feed_data('\027')
|
||||
screen_server:expect([[
|
||||
Hello, Worl^d |
|
||||
{100:~ }|*3
|
||||
{3:[No Name] [+] }|
|
||||
|
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
set_session(client_super)
|
||||
local screen_client = tt.setup_child_nvim({
|
||||
'--remote-ui',
|
||||
'--server',
|
||||
server_pipe,
|
||||
})
|
||||
|
||||
screen_client:expect([[
|
||||
Hello, Worl^d |
|
||||
{100:~ }|*3
|
||||
{3:[No Name] [+] }|
|
||||
|
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
local server_super, screen_server, screen_client = start_tui_and_remote_client()
|
||||
|
||||
-- quitting the server
|
||||
set_session(server_super)
|
||||
|
Reference in New Issue
Block a user