aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/autocmd/focus_spec.lua23
-rw-r--r--test/functional/core/main_spec.lua2
-rw-r--r--test/functional/core/startup_spec.lua2
-rw-r--r--test/functional/helpers.lua12
-rw-r--r--test/functional/terminal/api_spec.lua10
-rw-r--r--test/functional/terminal/tui_spec.lua365
-rw-r--r--test/functional/ui/screen.lua3
-rw-r--r--test/unit/tui_spec.lua2
8 files changed, 272 insertions, 147 deletions
diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua
index 024dccbe8e..d7a87e17ed 100644
--- a/test/functional/autocmd/focus_spec.lua
+++ b/test/functional/autocmd/focus_spec.lua
@@ -33,18 +33,37 @@ describe('autoread TUI FocusGained/FocusLost', function()
helpers.write_file(path, '')
lfs.touch(path, os.time() - 10)
- feed_command('edit '..path)
- feed_data('\027[O')
screen:expect{grid=[[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
+ {5:[No Name] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+ feed_command('edit '..path)
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
{5:xtest-foo }|
:edit xtest-foo |
{3:-- TERMINAL --} |
]]}
+ feed_data('\027[O')
+ feed_data('\027[O')
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:xtest-foo }|
+ :edit xtest-foo |
+ {3:-- TERMINAL --} |
+ ]], unchanged=true}
helpers.write_file(path, expected_addition)
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 53461f505a..ab11e14a67 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -56,7 +56,7 @@ describe('Command-line option', function()
screen:attach()
local args = {
nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE',
- '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
+ '--cmd', '"set noswapfile shortmess+=IFW fileformats=unix"',
'-s', '-'
}
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 9e22efa545..72d8f3a103 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -544,7 +544,7 @@ describe('sysinit', function()
nvim_exec() |
cmd: aunmenu * |
> |
- <" -u NONE -i NONE --cmd "set noruler" -D 1,1 All|
+ <" -u NONE -i NONE --cmd "set noruler" -D 1,0-1 All|
|
]])
command([[call chansend(g:id, "cont\n")]])
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index ca59eb3182..a14bedbbbd 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -243,7 +243,7 @@ function module.run_session(lsession, request_cb, notification_cb, setup_cb, tim
end
loop_running = true
- session:run(on_request, on_notification, on_setup, timeout)
+ lsession:run(on_request, on_notification, on_setup, timeout)
loop_running = false
if last_error then
local err = last_error
@@ -251,7 +251,7 @@ function module.run_session(lsession, request_cb, notification_cb, setup_cb, tim
error(err)
end
- return session.eof_err
+ return lsession.eof_err
end
function module.run(request_cb, notification_cb, setup_cb, timeout)
@@ -465,8 +465,14 @@ end
-- clear('-e')
-- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}}
function module.clear(...)
+ module.set_session(module.spawn_argv(false, ...))
+end
+
+-- same params as clear, but does returns the session instead
+-- of replacing the default session
+function module.spawn_argv(keep, ...)
local argv, env, io_extra = module.new_argv(...)
- module.set_session(module.spawn(argv, nil, env, nil, io_extra))
+ return module.spawn(argv, nil, env, keep, io_extra)
end
-- Builds an argument list for use in clear().
diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua
index 38ef7c2a61..724791343d 100644
--- a/test/functional/terminal/api_spec.lua
+++ b/test/functional/terminal/api_spec.lua
@@ -19,6 +19,16 @@ describe('api', function()
end)
it("qa! RPC request during insert-mode", function()
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+
-- Start the socket from the child nvim.
child_session.feed_data(":echo serverstart('"..socket_name.."')\n")
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 0ede6c9978..964fc8941d 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -24,8 +24,11 @@ local funcs = helpers.funcs
local meths = helpers.meths
local is_ci = helpers.is_ci
local is_os = helpers.is_os
-local spawn = helpers.spawn
+local new_pipename = helpers.new_pipename
+local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session
+local feed = helpers.feed
+local eval = helpers.eval
if helpers.skip(helpers.is_os('win')) then return end
@@ -36,7 +39,7 @@ describe('TUI', function()
before_each(function()
clear()
- local child_server = helpers.new_pipename()
+ local child_server = new_pipename()
screen = thelpers.screen_setup(0,
string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
nvim_prog, child_server, nvim_set))
@@ -1193,6 +1196,15 @@ describe('TUI', function()
it('paste: split "start paste" code', function()
feed_data('i')
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]]}
-- Send split "start paste" sequence.
feed_data('\027[2')
feed_data('00~pasted from terminal\027[201~')
@@ -1209,6 +1221,15 @@ describe('TUI', function()
it('paste: split "stop paste" code', function()
feed_data('i')
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]]}
-- Send split "stop paste" sequence.
feed_data('\027[200~pasted from terminal\027[20')
feed_data('1~')
@@ -1234,6 +1255,15 @@ describe('TUI', function()
end)(vim.paste)
]], {})
feed_data('i')
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]]}
feed_data('\027[200~pasted') -- phase 1
screen:expect([[
pasted{1: } |
@@ -1469,6 +1499,15 @@ describe('TUI', function()
it('<C-h> #10134', function()
local screen = thelpers.screen_setup(0, '["'..nvim_prog
..[[", "-u", "NONE", "-i", "NONE", "--cmd", "set noruler", "--cmd", ':nnoremap <C-h> :echomsg "\<C-h\>"<CR>']]..']')
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
command([[call chansend(b:terminal_job_id, "\<C-h>")]])
screen:expect([[
@@ -1495,6 +1534,15 @@ describe('TUI UIEnter/UILeave', function()
..[[, "--cmd", "autocmd VimEnter * :call add(g:evs, 'VimEnter')"]]
..']'
)
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
feed_data(":echo g:evs\n")
screen:expect{grid=[[
{1: } |
@@ -1515,61 +1563,88 @@ describe('TUI FocusGained/FocusLost', function()
clear()
screen = thelpers.screen_setup(0, '["'..nvim_prog
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
- feed_data(":autocmd FocusGained * echo 'gained'\n")
- feed_data(":autocmd FocusLost * echo 'lost'\n")
- feed_data("\034\016") -- CTRL-\ CTRL-N
- end)
-
- it('in normal-mode', function()
- retry(2, 3 * screen.timeout, function()
- feed_data('\027[I')
- screen:expect([[
+ screen:expect{grid=[[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] }|
- gained |
+ |
{3:-- TERMINAL --} |
- ]])
+ ]]}
+ feed_data(":autocmd FocusGained * echo 'gained'\n")
+ feed_data(":autocmd FocusLost * echo 'lost'\n")
+ feed_data("\034\016") -- CTRL-\ CTRL-N
+ end)
- feed_data('\027[O')
- screen:expect([[
+ it('in normal-mode', function()
+ screen:expect{grid=[[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] }|
- lost |
+ :autocmd FocusLost * echo 'lost' |
{3:-- TERMINAL --} |
- ]])
+ ]]}
+ retry(2, 3 * screen.timeout, function()
+ feed_data('\027[I')
+ screen:expect([[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ gained |
+ {3:-- TERMINAL --} |
+ ]])
+
+ feed_data('\027[O')
+ screen:expect([[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ lost |
+ {3:-- TERMINAL --} |
+ ]])
end)
end)
it('in insert-mode', function()
feed_command('set noshowmode')
feed_data('i')
- retry(2, 3 * screen.timeout, function()
- feed_data('\027[I')
- screen:expect([[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] }|
- gained |
- {3:-- TERMINAL --} |
- ]])
- feed_data('\027[O')
- screen:expect([[
+ screen:expect{grid=[[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] }|
- lost |
+ :set noshowmode |
{3:-- TERMINAL --} |
- ]])
+ ]]}
+ retry(2, 3 * screen.timeout, function()
+ feed_data('\027[I')
+ screen:expect([[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ gained |
+ {3:-- TERMINAL --} |
+ ]])
+ feed_data('\027[O')
+ screen:expect([[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ lost |
+ {3:-- TERMINAL --} |
+ ]])
end)
end)
@@ -1606,6 +1681,15 @@ describe('TUI FocusGained/FocusLost', function()
feed_data(":autocmd!\n")
feed_data(":autocmd FocusLost * call append(line('$'), 'lost')\n")
feed_data(":autocmd FocusGained * call append(line('$'), 'gained')\n")
+ screen:expect{grid=[[
+ {1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
retry(2, 3 * screen.timeout, function()
-- Enter cmdline-mode.
feed_data(':')
@@ -1664,9 +1748,18 @@ describe('TUI FocusGained/FocusLost', function()
feed_data(":echom 'msg1'|echom 'msg2'|echom 'msg3'|echom 'msg4'|echom 'msg5'\n")
-- Execute :messages to provoke the press-enter prompt.
feed_data(":messages\n")
+ screen:expect{grid=[[
+ msg1 |
+ msg2 |
+ msg3 |
+ msg4 |
+ msg5 |
+ {10:Press ENTER or type command to continue}{1: } |
+ {3:-- TERMINAL --} |
+ ]]}
feed_data('\027[I')
feed_data('\027[I')
- screen:expect([[
+ screen:expect{grid=[[
msg1 |
msg2 |
msg3 |
@@ -1674,7 +1767,7 @@ describe('TUI FocusGained/FocusLost', function()
msg5 |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]])
+ ]], unchanged=true}
end)
end)
@@ -2042,7 +2135,7 @@ describe("TUI", function()
retry(nil, 3000, function() -- Wait for log file to be flushed.
local log = read_file('Xtest_tui_verbose_log') or ''
- eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n'))
+ eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n')) -- }}}
ok(#log > 50)
end)
end)
@@ -2171,164 +2264,160 @@ end)
-- does not initialize the TUI.
describe("TUI as a client", function()
- it("connects to remote instance (full)", function()
- clear()
- local server_super = spawn(helpers.nvim_argv)
- local client_super = spawn(helpers.nvim_argv)
-
- set_session(server_super, true)
- screen_server = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--listen", "127.0.0.1:7777"]')
-
- helpers.feed("iHello, World<esc>")
+ it("connects to remote instance (with its own TUI)", function()
+ local server_super = spawn_argv(false) -- equivalent to clear()
+ local client_super = spawn_argv(true)
- set_session(client_super, true)
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--connect", "127.0.0.1:7777"]')
+ set_session(server_super)
+ local server_pipe = new_pipename()
+ local screen_server = thelpers.screen_setup(0,
+ string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
+ nvim_prog, server_pipe, nvim_set))
- screen.timeout = 1000
- screen:expect([[
+ feed_data("iHello, World")
+ screen_server:expect{grid=[[
+ Hello, World{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]]}
+ feed_data("\027")
+ screen_server:expect{grid=[[
Hello, Worl{1:d} |
{4:~ }|
{4:~ }|
{4:~ }|
- {5:[No Name] [+] 1,12 All}|
+ {5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]])
+ ]]}
+
+ set_session(client_super)
+ local screen_client = thelpers.screen_setup(0,
+ string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
+ nvim_prog, server_pipe))
+
+ screen_client:expect{grid=[[
+ Hello, Worl{1:d} |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]]}
feed_data(":q!\n")
- -- tear down
- helpers.feed("<esc>:q!<CR>")
- set_session(server_super, true)
- helpers.feed("<esc>:q!<CR>")
server_super:close()
client_super:close()
end)
it("connects to remote instance (--headless)", function()
- local server = spawn({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--listen', '127.0.0.1:7777', '-c', ":%! echo 'Hello, World'" })
- -- wait till the server session starts
- helpers.sleep(1000)
+ local server = helpers.spawn_argv(false) -- equivalent to clear()
+ local client_super = spawn_argv(true)
- clear()
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--connect", "127.0.0.1:7777"]')
+ set_session(server)
+ local server_pipe = eval'v:servername'
+ feed'iHalloj!<esc>'
- screen.timeout = 1000
- screen:expect([[
- {1:H}ello, World |
+ set_session(client_super)
+ local screen = thelpers.screen_setup(0,
+ string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
+ nvim_prog, server_pipe))
+
+ screen:expect{grid=[[
+ Halloj{1:!} |
+ {4:~ }|
{4:~ }|
{4:~ }|
{4:~ }|
- {5:[No Name] [+] 1,1 All}|
|
{3:-- TERMINAL --} |
- ]])
+ ]]}
- feed_data(":q!\n")
+ client_super:close()
server:close()
end)
- it("connects to remote instance (pipe)", function()
+
+ it("throws error when no server exists", function()
clear()
- local server_super = spawn(helpers.nvim_argv)
- local client_super = spawn(helpers.nvim_argv)
+ local screen = thelpers.screen_setup(0,
+ string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "127.0.0.1:2436546", "--remote-ui"]]=],
+ nvim_prog))
- set_session(server_super, true)
- screen_server = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--listen", "127.0.0.119"]')
+ screen:try_resize(60, 7)
- helpers.feed("iHello, World<esc>")
+ screen:expect([[
+ Remote ui failed to start: {MATCH:.*}|
+ |
+ [Process exited 1]{1: } |
+ |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ end)
- set_session(client_super, true)
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--connect", "127.0.0.119"]')
+ it("exits when server quits", function()
+ local server_super = spawn_argv(false) -- equivalent to clear()
+ local client_super = spawn_argv(true)
- screen.timeout = 1000
- screen:expect([[
+ set_session(server_super)
+ local server_pipe = new_pipename()
+ local screen_server = thelpers.screen_setup(0,
+ string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
+ nvim_prog, server_pipe, nvim_set))
+
+ feed_data("iHello, World")
+ screen_server:expect{grid=[[
+ Hello, World{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]]}
+ feed_data("\027")
+ screen_server:expect{grid=[[
Hello, Worl{1:d} |
{4:~ }|
{4:~ }|
{4:~ }|
- {5:[No Name] [+] 1,12 All}|
+ {5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]])
-
- feed_data(":q!\n")
-
- -- tear down
- helpers.feed("<esc>:q!<CR>")
- set_session(server_super, true)
- helpers.feed("<esc>:q!<CR>")
- server_super:close()
- client_super:close()
- end)
-
- it("throws error when no server exists", function()
- clear()
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--connect", "127.0.0.1:7777"]')
+ ]]}
- screen.timeout = 1000
- screen:expect([[
- Could not establish connection with remote server |
- |
- [Process exited 1]{1: } |
- |
- |
- |
- {3:-- TERMINAL --} |
- ]])
- end)
+ set_session(client_super)
+ local screen_client = thelpers.screen_setup(0,
+ string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
+ nvim_prog, server_pipe))
- it("exits when server quits", function()
- clear()
- local server_super = spawn(helpers.nvim_argv)
- local client_super = spawn(helpers.nvim_argv)
-
- set_session(server_super, true)
- screen_server = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--listen", "127.0.0.1:7777"]')
-
- helpers.feed("iHello, World<esc>")
-
- set_session(client_super, true)
- screen_client = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--connect", "127.0.0.1:7777"]')
-
- -- assert that client has connected to server
- screen_client.timeout = 1000
- screen_client:expect([[
+ screen_client:expect{grid=[[
Hello, Worl{1:d} |
{4:~ }|
{4:~ }|
{4:~ }|
- {5:[No Name] [+] 1,12 All}|
+ {5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]])
+ ]]}
-- quitting the server
- set_session(server_super, true)
+ set_session(server_super)
feed_data(":q!\n")
- screen_server.timeout = 1000
screen_server:expect({any="Process exited 0"})
-- assert that client has exited
- set_session(client_super, true)
screen_client:expect({any="Process exited 0"})
- -- tear down
- helpers.feed("<esc>:q!<CR>")
- set_session(server_super, true)
- helpers.feed("<esc>:q!<CR>")
server_super:close()
client_super:close()
-
- -- Restore the original session
- set_session(spawn(helpers.nvim_argv), true)
end)
end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 79927273a6..3b9cce0e6f 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -1550,7 +1550,8 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id)
attr_state.modified = true
return id
end
- return "UNEXPECTED "..self:_pprint_attrs(self._attr_table[hl_id][1])
+ local kind = self._options.rgb and 1 or 2
+ return "UNEXPECTED "..self:_pprint_attrs(self._attr_table[hl_id][kind])
else
if self:_equal_attrs(attrs, {}) then
-- ignore this attrs
diff --git a/test/unit/tui_spec.lua b/test/unit/tui_spec.lua
index 36ce4a1493..15b019edd1 100644
--- a/test/unit/tui_spec.lua
+++ b/test/unit/tui_spec.lua
@@ -33,7 +33,7 @@ itp('handle_background_color', function()
term_input.waiting_for_bg_response = 1
eq(kComplete, handle_background_color(term_input))
eq(0, term_input.waiting_for_bg_response)
- eq(1, multiqueue.multiqueue_size(events))
+ eq(0, multiqueue.multiqueue_size(events))
local event = multiqueue.multiqueue_get(events)
local bg_event = ffi.cast("Event*", event.argv[1])