mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
Merge pull request #36005 from zeertzjq/backport
test(tui_spec): deduplicate (#36003)
This commit is contained in:
@@ -3213,10 +3213,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)
|
||||||
@@ -3236,7 +3232,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')
|
||||||
@@ -3248,7 +3248,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)
|
||||||
@@ -3580,19 +3580,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',
|
||||||
@@ -3603,27 +3598,31 @@ describe('TUI client', function()
|
|||||||
'--cmd',
|
'--cmd',
|
||||||
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
||||||
})
|
})
|
||||||
|
screen_server:expect([[
|
||||||
|
^ |
|
||||||
|
{4:~ }|*3
|
||||||
|
{5:[No Name] }|
|
||||||
|
|
|
||||||
|
{3:-- TERMINAL --} |
|
||||||
|
]])
|
||||||
|
|
||||||
feed_data('iHello, World')
|
feed_data('iHello, World')
|
||||||
screen_server:expect {
|
screen_server:expect([[
|
||||||
grid = [[
|
|
||||||
Hello, World^ |
|
Hello, World^ |
|
||||||
{4:~ }|*3
|
{4:~ }|*3
|
||||||
{5:[No Name] [+] }|
|
{5:[No Name] [+] }|
|
||||||
{3:-- INSERT --} |
|
{3:-- INSERT --} |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]])
|
||||||
}
|
|
||||||
feed_data('\027')
|
feed_data('\027')
|
||||||
screen_server:expect {
|
local s0 = [[
|
||||||
grid = [[
|
|
||||||
Hello, Worl^d |
|
Hello, Worl^d |
|
||||||
{4:~ }|*3
|
{4:~ }|*3
|
||||||
{5:[No Name] [+] }|
|
{5:[No Name] [+] }|
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]]
|
||||||
}
|
screen_server:expect(s0)
|
||||||
|
|
||||||
set_session(client_super)
|
set_session(client_super)
|
||||||
local screen_client = tt.setup_child_nvim({
|
local screen_client = tt.setup_child_nvim({
|
||||||
@@ -3631,41 +3630,40 @@ describe('TUI client', function()
|
|||||||
'--server',
|
'--server',
|
||||||
server_pipe,
|
server_pipe,
|
||||||
})
|
})
|
||||||
|
screen_client:expect(s0)
|
||||||
|
|
||||||
screen_client:expect {
|
return server_super, screen_server, screen_client
|
||||||
grid = [[
|
end
|
||||||
Hello, Worl^d |
|
|
||||||
{4:~ }|*3
|
it('connects to remote instance (with its own TUI)', function()
|
||||||
{5:[No Name] [+] }|
|
local _, screen_server, screen_client = start_tui_and_remote_client()
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
|
|
||||||
-- grid smaller than containing terminal window is cleared properly
|
-- grid smaller than containing terminal window is cleared properly
|
||||||
feed_data(":call setline(1,['a'->repeat(&columns)]->repeat(&lines))\n")
|
feed_data(":call setline(1,['a'->repeat(&columns)]->repeat(&lines))\n")
|
||||||
feed_data('0:set lines=3\n')
|
feed_data('0:set lines=3\n')
|
||||||
screen_server:expect {
|
local s1 = [[
|
||||||
grid = [[
|
|
||||||
^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
||||||
{5:[No Name] [+] }|
|
{5:[No Name] [+] }|
|
||||||
|*4
|
|*4
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]]
|
||||||
}
|
screen_client:expect(s1)
|
||||||
|
screen_server:expect(s1)
|
||||||
|
|
||||||
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')
|
||||||
@@ -3676,28 +3674,29 @@ describe('TUI client', function()
|
|||||||
'--server',
|
'--server',
|
||||||
server_pipe,
|
server_pipe,
|
||||||
})
|
})
|
||||||
|
screen_client:expect([[
|
||||||
screen_client:expect {
|
|
||||||
grid = [[
|
|
||||||
Halloj^! |
|
Halloj^! |
|
||||||
{4:~ }|*4
|
{4:~ }|*4
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- 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')]])
|
||||||
screen_client:expect {
|
screen_client:expect([[
|
||||||
grid = [[
|
|
||||||
Nvim: Caught deadly signal 'SIGTERM' |
|
Nvim: Caught deadly signal 'SIGTERM' |
|
||||||
|
|
|
|
||||||
[Process exited 1]^ |
|
[Process exited 1]^ |
|
||||||
|*3
|
|*3
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]],
|
]])
|
||||||
}
|
|
||||||
|
|
||||||
eq(0, api.nvim_get_vvar('shell_error'))
|
eq(0, api.nvim_get_vvar('shell_error'))
|
||||||
-- exits on input eof #22244
|
-- exits on input eof #22244
|
||||||
@@ -3727,70 +3726,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 {
|
|
||||||
grid = [[
|
|
||||||
^ |
|
|
||||||
{4:~ }|*3
|
|
||||||
{5:[No Name] }|
|
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
|
|
||||||
feed_data('iHello, World')
|
|
||||||
screen_server:expect {
|
|
||||||
grid = [[
|
|
||||||
Hello, World^ |
|
|
||||||
{4:~ }|*3
|
|
||||||
{5:[No Name] [+] }|
|
|
||||||
{3:-- INSERT --} |
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
feed_data('\027')
|
|
||||||
screen_server:expect {
|
|
||||||
grid = [[
|
|
||||||
Hello, Worl^d |
|
|
||||||
{4:~ }|*3
|
|
||||||
{5:[No Name] [+] }|
|
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
|
|
||||||
set_session(client_super)
|
|
||||||
local screen_client = tt.setup_child_nvim({
|
|
||||||
'--remote-ui',
|
|
||||||
'--server',
|
|
||||||
server_pipe,
|
|
||||||
})
|
|
||||||
|
|
||||||
screen_client:expect {
|
|
||||||
grid = [[
|
|
||||||
Hello, Worl^d |
|
|
||||||
{4:~ }|*3
|
|
||||||
{5:[No Name] [+] }|
|
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
|
|
||||||
-- quitting the server
|
-- quitting the server
|
||||||
set_session(server_super)
|
set_session(server_super)
|
||||||
|
Reference in New Issue
Block a user