mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
Merge pull request #22304 from zeertzjq/test-fix
Fix some mistakes and warnings in tests
This commit is contained in:
@@ -413,7 +413,7 @@ describe('named marks view', function()
|
|||||||
6 line |
|
6 line |
|
||||||
^7 line |
|
^7 line |
|
||||||
8 line |
|
8 line |
|
||||||
{MATCH:.*} |
|
{MATCH:.*marks} |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
|
||||||
|
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
|
local exec_capture = helpers.exec_capture
|
||||||
|
local matches = helpers.matches
|
||||||
local pathsep = helpers.get_pathsep()
|
local pathsep = helpers.get_pathsep()
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
@@ -29,147 +30,49 @@ describe(':trust', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('trust then deny then remove a file using current buffer', function()
|
it('trust then deny then remove a file using current buffer', function()
|
||||||
local screen = Screen.new(80, 8)
|
|
||||||
screen:attach()
|
|
||||||
screen:set_default_attr_ids({
|
|
||||||
[1] = {bold = true, foreground = Screen.colors.Blue1},
|
|
||||||
})
|
|
||||||
|
|
||||||
local cwd = funcs.getcwd()
|
local cwd = funcs.getcwd()
|
||||||
local hash = funcs.sha256(helpers.read_file('test_file'))
|
local hash = funcs.sha256(helpers.read_file('test_file'))
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
command('trust')
|
matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" trusted.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
||||||
|
|
||||||
command('trust ++deny')
|
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
||||||
|
|
||||||
command('trust ++remove')
|
matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format(''), vim.trim(trust))
|
eq(string.format(''), vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deny then trust then remove a file using current buffer', function()
|
it('deny then trust then remove a file using current buffer', function()
|
||||||
local screen = Screen.new(80, 8)
|
|
||||||
screen:attach()
|
|
||||||
screen:set_default_attr_ids({
|
|
||||||
[1] = {bold = true, foreground = Screen.colors.Blue1},
|
|
||||||
})
|
|
||||||
|
|
||||||
local cwd = funcs.getcwd()
|
local cwd = funcs.getcwd()
|
||||||
local hash = funcs.sha256(helpers.read_file('test_file'))
|
local hash = funcs.sha256(helpers.read_file('test_file'))
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
command('trust ++deny')
|
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
||||||
|
|
||||||
command('trust')
|
matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" trusted.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
||||||
|
|
||||||
command('trust ++remove')
|
matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove'))
|
||||||
screen:expect([[
|
|
||||||
^test |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format(''), vim.trim(trust))
|
eq(string.format(''), vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deny then remove a file using file path', function()
|
it('deny then remove a file using file path', function()
|
||||||
local screen = Screen.new(80, 8)
|
|
||||||
screen:attach()
|
|
||||||
screen:set_default_attr_ids({
|
|
||||||
[1] = {bold = true, foreground = Screen.colors.Blue1},
|
|
||||||
})
|
|
||||||
|
|
||||||
local cwd = funcs.getcwd()
|
local cwd = funcs.getcwd()
|
||||||
|
|
||||||
command('trust ++deny test_file')
|
matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny test_file'))
|
||||||
screen:expect([[
|
|
||||||
^ |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" denied.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
local trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust))
|
||||||
|
|
||||||
command('trust ++remove test_file')
|
matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove test_file'))
|
||||||
screen:expect([[
|
|
||||||
^ |
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
"]] .. cwd .. pathsep .. [[test_file" removed.{MATCH:%s+}|
|
|
||||||
]])
|
|
||||||
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
trust = helpers.read_file(funcs.stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format(''), vim.trim(trust))
|
eq(string.format(''), vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
@@ -48,6 +48,7 @@ describe('vim.secure', function()
|
|||||||
[4] = {reverse = true},
|
[4] = {reverse = true},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--- XXX: screen:expect() may fail if this path is too long.
|
||||||
local cwd = funcs.getcwd()
|
local cwd = funcs.getcwd()
|
||||||
|
|
||||||
-- Need to use feed_command instead of exec_lua because of the confirmation prompt
|
-- Need to use feed_command instead of exec_lua because of the confirmation prompt
|
||||||
@@ -59,7 +60,7 @@ describe('vim.secure', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{2: }|
|
{2: }|
|
||||||
:lua vim.secure.read('Xfile') |
|
:lua vim.secure.read('Xfile') |
|
||||||
{3:]] .. cwd .. pathsep .. [[Xfile is untrusted}{MATCH:%s+}|
|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH:%s+}|
|
||||||
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
||||||
]]}
|
]]}
|
||||||
feed('d')
|
feed('d')
|
||||||
@@ -88,7 +89,7 @@ describe('vim.secure', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{2: }|
|
{2: }|
|
||||||
:lua vim.secure.read('Xfile') |
|
:lua vim.secure.read('Xfile') |
|
||||||
{3:]] .. cwd .. pathsep .. [[Xfile is untrusted}{MATCH:%s+}|
|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH:%s+}|
|
||||||
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
||||||
]]}
|
]]}
|
||||||
feed('a')
|
feed('a')
|
||||||
@@ -118,7 +119,7 @@ describe('vim.secure', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{2: }|
|
{2: }|
|
||||||
:lua vim.secure.read('Xfile') |
|
:lua vim.secure.read('Xfile') |
|
||||||
{3:]] .. cwd .. pathsep .. [[Xfile is untrusted}{MATCH:%s+}|
|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH:%s+}|
|
||||||
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
||||||
]]}
|
]]}
|
||||||
feed('i')
|
feed('i')
|
||||||
@@ -145,7 +146,7 @@ describe('vim.secure', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{2: }|
|
{2: }|
|
||||||
:lua vim.secure.read('Xfile') |
|
:lua vim.secure.read('Xfile') |
|
||||||
{3:]] .. cwd .. pathsep .. [[Xfile is untrusted}{MATCH:%s+}|
|
{3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH:%s+}|
|
||||||
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^ |
|
||||||
]]}
|
]]}
|
||||||
feed('v')
|
feed('v')
|
||||||
@@ -153,7 +154,7 @@ describe('vim.secure', function()
|
|||||||
^let g:foobar = 42 |
|
^let g:foobar = 42 |
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{2:]] .. funcs.fnamemodify(cwd, ':~') .. pathsep .. [[Xfile [RO]{MATCH:%s+}|
|
{2:]] .. funcs.fnamemodify(cwd, ':~') .. pathsep .. [[Xfile [RO]{MATCH:%s+}}|
|
||||||
|
|
|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{4:[No Name] }|
|
{4:[No Name] }|
|
||||||
|
@@ -109,14 +109,14 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts resize while pager is active', function()
|
it('accepts resize while pager is active', function()
|
||||||
child_session:request("nvim_command", [[
|
child_session:request("nvim_exec", [[
|
||||||
set more
|
set more
|
||||||
func! ManyErr()
|
func! ManyErr()
|
||||||
for i in range(10)
|
for i in range(10)
|
||||||
echoerr "FAIL ".i
|
echoerr "FAIL ".i
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
]])
|
]], false)
|
||||||
feed_data(':call ManyErr()\r')
|
feed_data(':call ManyErr()\r')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{8:Error detected while processing function ManyErr:} |
|
{8:Error detected while processing function ManyErr:} |
|
||||||
@@ -302,11 +302,11 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts mouse wheel events #19992', function()
|
it('accepts mouse wheel events #19992', function()
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
set number nostartofline nowrap mousescroll=hor:1,ver:1
|
set number nostartofline nowrap mousescroll=hor:1,ver:1
|
||||||
call setline(1, repeat([join(range(10), '----')], 10))
|
call setline(1, repeat([join(range(10), '----')], 10))
|
||||||
vsplit
|
vsplit
|
||||||
]])
|
]], false)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
||||||
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
|
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
|
||||||
@@ -632,11 +632,11 @@ describe('TUI', function()
|
|||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
tab split
|
tab split
|
||||||
tabnew
|
tabnew
|
||||||
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
|
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
|
||||||
]])
|
]], false)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
|
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
|
||||||
{1: } |
|
{1: } |
|
||||||
@@ -669,7 +669,7 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('mouse events work with right-click menu', function()
|
it('mouse events work with right-click menu', function()
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
call setline(1, 'popup menu test')
|
call setline(1, 'popup menu test')
|
||||||
set mouse=a mousemodel=popup
|
set mouse=a mousemodel=popup
|
||||||
|
|
||||||
@@ -679,7 +679,7 @@ describe('TUI', function()
|
|||||||
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
||||||
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
||||||
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
||||||
]])
|
]], false)
|
||||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -1544,7 +1544,7 @@ describe('TUI', function()
|
|||||||
{2:~ }│{4:~ }|
|
{2:~ }│{4:~ }|
|
||||||
{2:~ }│{5:[No Name] 0,0-1 All}|
|
{2:~ }│{5:[No Name] 0,0-1 All}|
|
||||||
{2:~ }│ |
|
{2:~ }│ |
|
||||||
{5:new }{MATCH:<.*[/\]nvim }|
|
{5:new }{1:{MATCH:<.*[/\]nvim }}|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
@@ -1626,12 +1626,16 @@ end)
|
|||||||
|
|
||||||
describe('TUI FocusGained/FocusLost', function()
|
describe('TUI FocusGained/FocusLost', function()
|
||||||
local screen
|
local screen
|
||||||
|
local child_session
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = thelpers.screen_setup(0, '["'..nvim_prog
|
local child_server = new_pipename()
|
||||||
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
screen = thelpers.screen_setup(0,
|
||||||
screen:expect{grid=[[
|
string.format(
|
||||||
|
[=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]]=],
|
||||||
|
nvim_prog, child_server))
|
||||||
|
screen:expect([[
|
||||||
{1: } |
|
{1: } |
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
@@ -1639,22 +1643,16 @@ describe('TUI FocusGained/FocusLost', function()
|
|||||||
{5:[No Name] }|
|
{5:[No Name] }|
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]]}
|
]])
|
||||||
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
child_session = helpers.connect(child_server)
|
||||||
feed_data(":autocmd FocusLost * echo 'lost'\n")
|
child_session:request('nvim_exec', [[
|
||||||
|
autocmd FocusGained * echo 'gained'
|
||||||
|
autocmd FocusLost * echo 'lost'
|
||||||
|
]], false)
|
||||||
feed_data("\034\016") -- CTRL-\ CTRL-N
|
feed_data("\034\016") -- CTRL-\ CTRL-N
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('in normal-mode', function()
|
it('in normal-mode', function()
|
||||||
screen:expect{grid=[[
|
|
||||||
{1: } |
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{5:[No Name] }|
|
|
||||||
:autocmd FocusLost * echo 'lost' |
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]]}
|
|
||||||
retry(2, 3 * screen.timeout, function()
|
retry(2, 3 * screen.timeout, function()
|
||||||
feed_data('\027[I')
|
feed_data('\027[I')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -1746,18 +1744,11 @@ describe('TUI FocusGained/FocusLost', function()
|
|||||||
-- Set up autocmds that modify the buffer, instead of just calling :echo.
|
-- Set up autocmds that modify the buffer, instead of just calling :echo.
|
||||||
-- This is how we can test handling of focus gained/lost during cmdline-mode.
|
-- This is how we can test handling of focus gained/lost during cmdline-mode.
|
||||||
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
|
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
|
||||||
feed_data(":autocmd!\n")
|
child_session:request('nvim_exec', [[
|
||||||
feed_data(":autocmd FocusLost * call append(line('$'), 'lost')\n")
|
autocmd!
|
||||||
feed_data(":autocmd FocusGained * call append(line('$'), 'gained')\n")
|
autocmd FocusLost * call append(line('$'), 'lost')
|
||||||
screen:expect{grid=[[
|
autocmd FocusGained * call append(line('$'), 'gained')
|
||||||
{1: } |
|
]], false)
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{5:[No Name] }|
|
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]]}
|
|
||||||
retry(2, 3 * screen.timeout, function()
|
retry(2, 3 * screen.timeout, function()
|
||||||
-- Enter cmdline-mode.
|
-- Enter cmdline-mode.
|
||||||
feed_data(':')
|
feed_data(':')
|
||||||
|
@@ -303,7 +303,7 @@ describe('Buffer highlighting', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
2 change3; before #3 {MATCH:.*}|
|
2 changes; before #3 {MATCH:.*}|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
command('undo')
|
command('undo')
|
||||||
|
@@ -1322,7 +1322,7 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }type :q{5:<Enter>} to exit {1: }|
|
{1:~ }type :q{5:<Enter>} to exit {1: }|
|
||||||
{1:~ }type :help{5:<Enter>} for help {1: }|
|
{1:~ }type :help{5:<Enter>} for help {1: }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}|
|
{1:~{MATCH: +}}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{MATCH:.*}|
|
{MATCH:.*}|
|
||||||
{MATCH:.*}|
|
{MATCH:.*}|
|
||||||
@@ -1378,7 +1378,7 @@ describe('ui/ext_messages', function()
|
|||||||
type :q{5:<Enter>} to exit |
|
type :q{5:<Enter>} to exit |
|
||||||
type :help{5:<Enter>} for help |
|
type :help{5:<Enter>} for help |
|
||||||
|
|
|
|
||||||
type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}|
|
{MATCH: +}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+ +}|
|
||||||
|
|
|
|
||||||
{MATCH:.*}|
|
{MATCH:.*}|
|
||||||
{MATCH:.*}|
|
{MATCH:.*}|
|
||||||
|
@@ -75,6 +75,7 @@ local busted = require('busted')
|
|||||||
local deepcopy = helpers.deepcopy
|
local deepcopy = helpers.deepcopy
|
||||||
local shallowcopy = helpers.shallowcopy
|
local shallowcopy = helpers.shallowcopy
|
||||||
local concat_tables = helpers.concat_tables
|
local concat_tables = helpers.concat_tables
|
||||||
|
local pesc = helpers.pesc
|
||||||
local run_session = helpers.run_session
|
local run_session = helpers.run_session
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local dedent = helpers.dedent
|
local dedent = helpers.dedent
|
||||||
@@ -257,7 +258,7 @@ local ext_keys = {
|
|||||||
-- grid: Expected screen state (string). Each line represents a screen
|
-- grid: Expected screen state (string). Each line represents a screen
|
||||||
-- row. Last character of each row (typically "|") is stripped.
|
-- row. Last character of each row (typically "|") is stripped.
|
||||||
-- Common indentation is stripped.
|
-- Common indentation is stripped.
|
||||||
-- "{MATCH:x}|" lines are matched against Lua pattern `x`.
|
-- "{MATCH:x}" in a line is matched against Lua pattern `x`.
|
||||||
-- attr_ids: Expected text attributes. Screen rows are transformed according
|
-- attr_ids: Expected text attributes. Screen rows are transformed according
|
||||||
-- to this table, as follows: each substring S composed of
|
-- to this table, as follows: each substring S composed of
|
||||||
-- characters having the same attributes will be substituted by
|
-- characters having the same attributes will be substituted by
|
||||||
@@ -382,8 +383,20 @@ function Screen:expect(expected, attr_ids, ...)
|
|||||||
end
|
end
|
||||||
for i, row in ipairs(expected_rows) do
|
for i, row in ipairs(expected_rows) do
|
||||||
msg_expected_rows[i] = row
|
msg_expected_rows[i] = row
|
||||||
local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil)
|
local pat = nil
|
||||||
if row ~= actual_rows[i] and (not m or not (actual_rows[i] and actual_rows[i]:match(m))) then
|
if actual_rows[i] and row ~= actual_rows[i] then
|
||||||
|
local after = row
|
||||||
|
while true do
|
||||||
|
local s, e, m = after:find('{MATCH:(.-)}')
|
||||||
|
if not s then
|
||||||
|
pat = pat and (pat .. pesc(after))
|
||||||
|
break
|
||||||
|
end
|
||||||
|
pat = (pat or '') .. pesc(after:sub(1, s - 1)) .. m
|
||||||
|
after = after:sub(e + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if row ~= actual_rows[i] and (not pat or not actual_rows[i]:match(pat)) then
|
||||||
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
||||||
if i <= #actual_rows then
|
if i <= #actual_rows then
|
||||||
actual_rows[i] = '*' .. actual_rows[i]
|
actual_rows[i] = '*' .. actual_rows[i]
|
||||||
|
Reference in New Issue
Block a user