aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/helpers.lua1
-rw-r--r--test/functional/shell/bang_filter_spec.lua49
-rw-r--r--test/functional/terminal/helpers.lua46
-rw-r--r--test/functional/terminal/tui_spec.lua106
-rw-r--r--test/functional/ui/input_spec.lua70
-rw-r--r--test/functional/ui/screen.lua3
6 files changed, 254 insertions, 21 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 9cd1fd7ab3..80cb1e5ce3 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -372,5 +372,6 @@ return {
set_session = set_session,
write_file = write_file,
rmdir = rmdir,
+ mkdir = lfs.mkdir,
exc_exec = exc_exec,
}
diff --git a/test/functional/shell/bang_filter_spec.lua b/test/functional/shell/bang_filter_spec.lua
new file mode 100644
index 0000000000..964dbd1029
--- /dev/null
+++ b/test/functional/shell/bang_filter_spec.lua
@@ -0,0 +1,49 @@
+-- Specs for bang/filter commands
+
+local helpers = require('test.functional.helpers')
+local feed, execute, clear = helpers.feed, helpers.execute, helpers.clear
+local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdir
+
+local Screen = require('test.functional.ui.screen')
+
+
+describe('issues', function()
+ local screen
+
+ before_each(function()
+ clear()
+ rmdir('bang_filter_spec')
+ mkdir('bang_filter_spec')
+ write_file('bang_filter_spec/f1', 'f1')
+ write_file('bang_filter_spec/f2', 'f2')
+ write_file('bang_filter_spec/f3', 'f3')
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ rmdir('bang_filter_spec')
+ end)
+
+ it('#3269 Last line of shell output is not truncated', function()
+ execute([[nnoremap <silent>\l :!ls bang_filter_spec<cr>]])
+ feed([[\l]])
+ screen:expect([[
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :!ls bang_filter_spec |
+ |
+ f1 |
+ f2 |
+ f3 |
+ Press ENTER or type command to continue^ |
+ ]])
+ end)
+
+end)
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index e488495139..ae13aab277 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local nvim_dir = helpers.nvim_dir
-local execute, nvim = helpers.execute, helpers.nvim
+local execute, nvim, wait = helpers.execute, helpers.nvim, helpers.wait
local function feed_data(data)
nvim('set_var', 'term_data', data)
@@ -31,13 +31,15 @@ local function clear_attrs() feed_termcode('[0;10m') end
local function enable_mouse() feed_termcode('[?1002h') end
local function disable_mouse() feed_termcode('[?1002l') end
+local default_command = '["'..nvim_dir..'/tty-test'..'"]'
-local function screen_setup(extra_height)
+local function screen_setup(extra_height, command)
nvim('command', 'highlight TermCursor cterm=reverse')
nvim('command', 'highlight TermCursorNC ctermbg=11')
nvim('set_var', 'terminal_scrollback_buffer_size', 10)
if not extra_height then extra_height = 0 end
+ if not command then command = default_command end
local screen = Screen.new(50, 7 + extra_height)
screen:set_default_attr_ids({
[1] = {reverse = true}, -- focused cursor
@@ -56,25 +58,29 @@ local function screen_setup(extra_height)
-- tty-test puts the terminal into raw mode and echoes all input. tests are
-- done by feeding it with terminfo codes to control the display and
-- verifying output with screen:expect.
- execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
- -- wait for "tty ready" to be printed before each test or the terminal may
- -- still be in canonical mode(will echo characters for example)
- --
- local empty_line = ' '
- local expected = {
- 'tty ready ',
- '{1: } ',
- empty_line,
- empty_line,
- empty_line,
- empty_line,
- }
- for i = 1, extra_height do
- table.insert(expected, empty_line)
- end
+ execute('enew | call termopen('..command..') | startinsert')
+ if command == default_command then
+ -- wait for "tty ready" to be printed before each test or the terminal may
+ -- still be in canonical mode(will echo characters for example)
+ --
+ local empty_line = ' '
+ local expected = {
+ 'tty ready ',
+ '{1: } ',
+ empty_line,
+ empty_line,
+ empty_line,
+ empty_line,
+ }
+ for i = 1, extra_height do
+ table.insert(expected, empty_line)
+ end
- table.insert(expected, '-- TERMINAL -- ')
- screen:expect(table.concat(expected, '\n'))
+ table.insert(expected, '-- TERMINAL -- ')
+ screen:expect(table.concat(expected, '\n'))
+ else
+ wait()
+ end
return screen
end
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
new file mode 100644
index 0000000000..d604703fee
--- /dev/null
+++ b/test/functional/terminal/tui_spec.lua
@@ -0,0 +1,106 @@
+-- Some sanity checks for the TUI using the builtin terminal emulator
+-- as a simple way to send keys and assert screen state.
+local Screen = require('test.functional.ui.screen')
+local helpers = require('test.functional.helpers')
+local thelpers = require('test.functional.terminal.helpers')
+local feed = thelpers.feed_data
+local execute = helpers.execute
+
+describe('tui', function()
+ local screen
+
+ before_each(function()
+ helpers.clear()
+ screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "--cmd", "set noswapfile"]')
+ screen.timeout = 30000 -- pasting can be really slow in the TUI
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('accepts basic utf-8 input', function()
+ feed('iabc\ntest1\ntest2')
+ screen:expect([[
+ abc |
+ test1 |
+ test2{1: } |
+ ~ |
+ [No Name] [+] |
+ -- INSERT -- |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b')
+ screen:expect([[
+ abc |
+ test1 |
+ test{1:2} |
+ ~ |
+ [No Name] [+] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('automatically sends <Paste> for bracketed paste sequences', function()
+ feed('i\x1b[200~')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ -- INSERT (paste) -- |
+ -- TERMINAL -- |
+ ]])
+ feed('pasted from terminal')
+ screen:expect([[
+ pasted from terminal{1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] [+] |
+ -- INSERT (paste) -- |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[201~')
+ screen:expect([[
+ pasted from terminal{1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] [+] |
+ -- INSERT -- |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('can handle arbitrarily long bursts of input', function()
+ execute('set ruler')
+ local t = {}
+ for i = 1, 3000 do
+ t[i] = 'item ' .. tostring(i)
+ end
+ feed('i\x1b[200~')
+ feed(table.concat(t, '\n'))
+ feed('\x1b[201~')
+ screen:expect([[
+ item 2997 |
+ item 2998 |
+ item 2999 |
+ item 3000{1: } |
+ [No Name] [+] 3000,10 Bot|
+ -- INSERT -- |
+ -- TERMINAL -- |
+ ]])
+ end)
+end)
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index 81af908045..a7c8e02def 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')
local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim
local feed, next_message, eq = helpers.feed, helpers.next_message, helpers.eq
local expect = helpers.expect
+local Screen = require('test.functional.ui.screen')
describe('mappings', function()
local cid
@@ -40,7 +41,76 @@ describe('mappings', function()
end)
end)
+describe('feeding large chunks of input with <Paste>', function()
+ local screen
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ execute('set ruler')
+ end)
+
+ it('ok', function()
+ local t = {}
+ for i = 1, 20000 do
+ t[i] = 'item ' .. tostring(i)
+ end
+ feed('i<Paste>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ -- INSERT (paste) -- |
+ ]])
+ feed(table.concat(t, '<Enter>'))
+ screen:expect([[
+ item 19988 |
+ item 19989 |
+ item 19990 |
+ item 19991 |
+ item 19992 |
+ item 19993 |
+ item 19994 |
+ item 19995 |
+ item 19996 |
+ item 19997 |
+ item 19998 |
+ item 19999 |
+ item 20000^ |
+ -- INSERT (paste) -- |
+ ]])
+ feed('<Paste>')
+ screen:expect([[
+ item 19988 |
+ item 19989 |
+ item 19990 |
+ item 19991 |
+ item 19992 |
+ item 19993 |
+ item 19994 |
+ item 19995 |
+ item 19996 |
+ item 19997 |
+ item 19998 |
+ item 19999 |
+ item 20000^ |
+ -- INSERT -- 20000,11 Bot |
+ ]])
+ end)
+end)
+
describe('input utf sequences that contain CSI/K_SPECIAL', function()
+ before_each(clear)
it('ok', function()
feed('i…<esc>')
expect('…')
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 08c4bfae0b..1be83d745e 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -163,6 +163,7 @@ function Screen.new(width, height)
height = 14
end
local self = setmetatable({
+ timeout = default_screen_timeout,
title = '',
icon = '',
bell = false,
@@ -248,7 +249,7 @@ function Screen:wait(check, timeout)
return true
end
- run(nil, notification_cb, nil, timeout or default_screen_timeout)
+ run(nil, notification_cb, nil, timeout or self.timeout)
if not checked then
err = check()
end