test: retry(): Report number of retries. (#6475)
tui_spec.lua: Retry the terminal-mode test.
This commit is contained in:
parent
cd0a436622
commit
a34408ef7f
|
@ -246,12 +246,13 @@ local function retry(max, max_ms, fn)
|
|||
return result
|
||||
end
|
||||
if (max and tries >= max) or (luv.now() - start_time > timeout) then
|
||||
break
|
||||
if type(result) == "string" then
|
||||
result = "\nretry() attempts: "..tostring(tries).."\n"..result
|
||||
end
|
||||
error(result)
|
||||
end
|
||||
tries = tries + 1
|
||||
end
|
||||
-- Do not use pcall() for the final attempt, let the failure bubble up.
|
||||
return fn()
|
||||
end
|
||||
|
||||
local function clear(...)
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
-- as a simple way to send keys and assert screen state.
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
local feed = thelpers.feed_data
|
||||
local feed_data = thelpers.feed_data
|
||||
local execute = helpers.execute
|
||||
local nvim_dir = helpers.nvim_dir
|
||||
local retry = helpers.retry
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
|
||||
|
@ -34,7 +35,7 @@ describe('tui', function()
|
|||
end)
|
||||
|
||||
it('accepts basic utf-8 input', function()
|
||||
feed('iabc\ntest1\ntest2')
|
||||
feed_data('iabc\ntest1\ntest2')
|
||||
screen:expect([[
|
||||
abc |
|
||||
test1 |
|
||||
|
@ -44,7 +45,7 @@ describe('tui', function()
|
|||
{3:-- INSERT --} |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('\027')
|
||||
feed_data('\027')
|
||||
screen:expect([[
|
||||
abc |
|
||||
test1 |
|
||||
|
@ -60,7 +61,7 @@ describe('tui', function()
|
|||
local keys = 'dfghjkl'
|
||||
for c in keys:gmatch('.') do
|
||||
execute('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
|
||||
feed('\027'..c)
|
||||
feed_data('\027'..c)
|
||||
end
|
||||
screen:expect([[
|
||||
alt-j |
|
||||
|
@ -71,7 +72,7 @@ describe('tui', function()
|
|||
|
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('gg')
|
||||
feed_data('gg')
|
||||
screen:expect([[
|
||||
{1:a}lt-d |
|
||||
alt-f |
|
||||
|
@ -90,7 +91,7 @@ describe('tui', function()
|
|||
-- Example: for input ALT+j:
|
||||
-- * Vim (Nvim prior to #3982) sets high-bit, inserts "ê".
|
||||
-- * Nvim (after #3982) inserts "j".
|
||||
feed('i\027j')
|
||||
feed_data('i\027j')
|
||||
screen:expect([[
|
||||
j{1: } |
|
||||
{4:~ }|
|
||||
|
@ -103,10 +104,10 @@ describe('tui', function()
|
|||
end)
|
||||
|
||||
it('accepts ascii control sequences', function()
|
||||
feed('i')
|
||||
feed('\022\007') -- ctrl+g
|
||||
feed('\022\022') -- ctrl+v
|
||||
feed('\022\013') -- ctrl+m
|
||||
feed_data('i')
|
||||
feed_data('\022\007') -- ctrl+g
|
||||
feed_data('\022\022') -- ctrl+v
|
||||
feed_data('\022\013') -- ctrl+m
|
||||
screen:expect([[
|
||||
{9:^G^V^M}{1: } |
|
||||
{4:~ }|
|
||||
|
@ -119,7 +120,7 @@ describe('tui', function()
|
|||
end)
|
||||
|
||||
it('automatically sends <Paste> for bracketed paste sequences', function()
|
||||
feed('i\027[200~')
|
||||
feed_data('i\027[200~')
|
||||
screen:expect([[
|
||||
{1: } |
|
||||
{4:~ }|
|
||||
|
@ -129,7 +130,7 @@ describe('tui', function()
|
|||
{3:-- INSERT (paste) --} |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('pasted from terminal')
|
||||
feed_data('pasted from terminal')
|
||||
screen:expect([[
|
||||
pasted from terminal{1: } |
|
||||
{4:~ }|
|
||||
|
@ -139,7 +140,7 @@ describe('tui', function()
|
|||
{3:-- INSERT (paste) --} |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('\027[201~')
|
||||
feed_data('\027[201~')
|
||||
screen:expect([[
|
||||
pasted from terminal{1: } |
|
||||
{4:~ }|
|
||||
|
@ -157,7 +158,7 @@ describe('tui', function()
|
|||
for i = 1, 3000 do
|
||||
t[i] = 'item ' .. tostring(i)
|
||||
end
|
||||
feed('i\027[200~'..table.concat(t, '\n')..'\027[201~')
|
||||
feed_data('i\027[200~'..table.concat(t, '\n')..'\027[201~')
|
||||
screen:expect([[
|
||||
item 2997 |
|
||||
item 2998 |
|
||||
|
@ -180,7 +181,7 @@ describe('tui with non-tty file descriptors', function()
|
|||
it('can handle pipes as stdout and stderr', function()
|
||||
local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog
|
||||
..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
|
||||
feed(':w testF\n:q\n')
|
||||
feed_data(':w testF\n:q\n')
|
||||
screen:expect([[
|
||||
:w testF |
|
||||
:q |
|
||||
|
@ -200,12 +201,13 @@ describe('tui focus event handling', function()
|
|||
helpers.clear()
|
||||
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
|
||||
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
||||
execute('autocmd FocusGained * echo "gained"')
|
||||
execute('autocmd FocusLost * echo "lost"')
|
||||
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
||||
feed_data(":autocmd FocusLost * echo 'lost'\n")
|
||||
feed_data("\034\016") -- CTRL-\ CTRL-N
|
||||
end)
|
||||
|
||||
it('can handle focus events in normal mode', function()
|
||||
feed('\027[I')
|
||||
feed_data('\027[I')
|
||||
screen:expect([[
|
||||
{1: } |
|
||||
{4:~ }|
|
||||
|
@ -216,7 +218,7 @@ describe('tui focus event handling', function()
|
|||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
feed('\027[O')
|
||||
feed_data('\027[O')
|
||||
screen:expect([[
|
||||
{1: } |
|
||||
{4:~ }|
|
||||
|
@ -230,8 +232,8 @@ describe('tui focus event handling', function()
|
|||
|
||||
it('can handle focus events in insert mode', function()
|
||||
execute('set noshowmode')
|
||||
feed('i')
|
||||
feed('\027[I')
|
||||
feed_data('i')
|
||||
feed_data('\027[I')
|
||||
screen:expect([[
|
||||
{1: } |
|
||||
{4:~ }|
|
||||
|
@ -241,7 +243,7 @@ describe('tui focus event handling', function()
|
|||
gained |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('\027[O')
|
||||
feed_data('\027[O')
|
||||
screen:expect([[
|
||||
{1: } |
|
||||
{4:~ }|
|
||||
|
@ -254,8 +256,8 @@ describe('tui focus event handling', function()
|
|||
end)
|
||||
|
||||
it('can handle focus events in cmdline mode', function()
|
||||
feed(':')
|
||||
feed('\027[I')
|
||||
feed_data(':')
|
||||
feed_data('\027[I')
|
||||
screen:expect([[
|
||||
|
|
||||
{4:~ }|
|
||||
|
@ -265,7 +267,7 @@ describe('tui focus event handling', function()
|
|||
g{1:a}ined |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('\027[O')
|
||||
feed_data('\027[O')
|
||||
screen:expect([[
|
||||
|
|
||||
{4:~ }|
|
||||
|
@ -278,30 +280,36 @@ describe('tui focus event handling', function()
|
|||
end)
|
||||
|
||||
it('can handle focus events in terminal mode', function()
|
||||
execute('set shell='..nvim_dir..'/shell-test')
|
||||
execute('set laststatus=0')
|
||||
execute('set noshowmode')
|
||||
execute('terminal')
|
||||
feed('\027[I')
|
||||
screen:expect([[
|
||||
ready $ |
|
||||
[Process exited 0]{1: } |
|
||||
|
|
||||
|
|
||||
|
|
||||
gained |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed('\027[O')
|
||||
screen:expect([[
|
||||
ready $ |
|
||||
[Process exited 0]{1: } |
|
||||
|
|
||||
|
|
||||
|
|
||||
lost |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed_data(':set shell='..nvim_dir..'/shell-test\n')
|
||||
feed_data(':set noshowmode laststatus=0\n')
|
||||
|
||||
retry(2, 3 * screen.timeout, function()
|
||||
feed_data(':terminal\n')
|
||||
feed_data('\027[I')
|
||||
screen:expect([[
|
||||
ready $ |
|
||||
[Process exited 0]{1: } |
|
||||
|
|
||||
|
|
||||
|
|
||||
gained |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
feed_data('\027[O')
|
||||
screen:expect([[
|
||||
ready $ |
|
||||
[Process exited 0]{1: } |
|
||||
|
|
||||
|
|
||||
|
|
||||
lost |
|
||||
{3:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
-- If retry is needed...
|
||||
feed_data("\034\016") -- CTRL-\ CTRL-N
|
||||
feed_data(':bwipeout!\n')
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in New Issue