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