aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-04-09 00:12:26 +0300
committerZyX <kp-pav@yandex.ru>2017-04-09 03:24:08 +0300
commit65fb622000af8e3dbb65480e1581758ecf4ba3e2 (patch)
tree7d83429d3762b1f0a44d04eb8fc780eedc0ec049 /test/functional/terminal
parent9158cc171f46ebae0a0d3d1721aa5b7d829bcba5 (diff)
downloadrneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.tar.gz
rneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.tar.bz2
rneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.zip
functests: Replace execute with either command or feed_command
Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed.
Diffstat (limited to 'test/functional/terminal')
-rw-r--r--test/functional/terminal/buffer_spec.lua30
-rw-r--r--test/functional/terminal/cursor_spec.lua4
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua18
-rw-r--r--test/functional/terminal/helpers.lua8
-rw-r--r--test/functional/terminal/highlight_spec.lua16
-rw-r--r--test/functional/terminal/scrollback_spec.lua6
-rw-r--r--test/functional/terminal/tui_spec.lua20
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua8
8 files changed, 55 insertions, 55 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 129390a7a5..48b8512bf0 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
local wait = helpers.wait
-local eval, execute, source = helpers.eval, helpers.execute, helpers.source
+local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
local eq, neq = helpers.eq, helpers.neq
local write_file = helpers.write_file
@@ -13,7 +13,7 @@ describe('terminal buffer', function()
before_each(function()
clear()
- execute('set modifiable swapfile undolevels=20')
+ feed_command('set modifiable swapfile undolevels=20')
wait()
screen = thelpers.screen_setup()
end)
@@ -86,7 +86,7 @@ describe('terminal buffer', function()
it('sends data to the terminal when the "put" operator is used', function()
feed('<c-\\><c-n>gg"ayj')
- execute('let @a = "appended " . @a')
+ feed_command('let @a = "appended " . @a')
feed('"ap"ap')
screen:expect([[
^tty ready |
@@ -112,8 +112,8 @@ describe('terminal buffer', function()
it('sends data to the terminal when the ":put" command is used', function()
feed('<c-\\><c-n>gg"ayj')
- execute('let @a = "appended " . @a')
- execute('put a')
+ feed_command('let @a = "appended " . @a')
+ feed_command('put a')
screen:expect([[
^tty ready |
appended tty ready |
@@ -124,7 +124,7 @@ describe('terminal buffer', function()
:put a |
]])
-- line argument is only used to move the cursor
- execute('6put a')
+ feed_command('6put a')
screen:expect([[
tty ready |
appended tty ready |
@@ -147,7 +147,7 @@ describe('terminal buffer', function()
{4:~ }|
:bd! |
]])
- execute('bnext')
+ feed_command('bnext')
screen:expect([[
^ |
{4:~ }|
@@ -162,7 +162,7 @@ describe('terminal buffer', function()
it('handles loss of focus gracefully', function()
-- Change the statusline to avoid printing the file name, which varies.
nvim('set_option', 'statusline', '==========')
- execute('set laststatus=0')
+ feed_command('set laststatus=0')
-- Save the buffer number of the terminal for later testing.
local tbuf = eval('bufnr("%")')
@@ -191,16 +191,16 @@ describe('terminal buffer', function()
]])
neq(tbuf, eval('bufnr("%")'))
- execute('quit!') -- Should exit the new window, not the terminal.
+ feed_command('quit!') -- Should exit the new window, not the terminal.
eq(tbuf, eval('bufnr("%")'))
- execute('set laststatus=1') -- Restore laststatus to the default.
+ feed_command('set laststatus=1') -- Restore laststatus to the default.
end)
it('term_close() use-after-free #4393', function()
- execute('terminal yes')
+ feed_command('terminal yes')
feed([[<C-\><C-n>]])
- execute('bdelete!')
+ feed_command('bdelete!')
end)
end)
@@ -217,12 +217,12 @@ describe('No heap-buffer-overflow when using', function()
end)
it('termopen(echo) #3161', function()
- execute('edit ' .. testfilename)
+ feed_command('edit ' .. testfilename)
-- Move cursor away from the beginning of the line
feed('$')
-- Let termopen() modify the buffer
- execute('call termopen("echo")')
+ feed_command('call termopen("echo")')
wait()
- execute('bdelete!')
+ feed_command('bdelete!')
end)
end)
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index 84f14585fa..9ac9e85c72 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local nvim_dir, execute = helpers.nvim_dir, helpers.execute
+local nvim_dir, command = helpers.nvim_dir, helpers.command
local hide_cursor = thelpers.hide_cursor
local show_cursor = thelpers.show_cursor
@@ -138,7 +138,7 @@ describe('cursor with customized highlighting', function()
[3] = {bold = true},
})
screen:attach({rgb=false})
- execute('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
+ command('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
end)
it('overrides the default highlighting', function()
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 9bb683f25f..154374cda9 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq
-local execute, eval = helpers.execute, helpers.eval
+local feed_command, eval = helpers.feed_command, helpers.eval
if helpers.pending_win32(pending) then return end
@@ -23,11 +23,11 @@ describe(':terminal', function()
echomsg "msg3"
]])
-- Invoke a command that emits frequent terminal activity.
- execute([[terminal while true; do echo X; done]])
+ feed_command([[terminal while true; do echo X; done]])
helpers.feed([[<C-\><C-N>]])
wait()
helpers.sleep(10) -- Let some terminal activity happen.
- execute("messages")
+ feed_command("messages")
screen:expect([[
msg1 |
msg2 |
@@ -37,14 +37,14 @@ describe(':terminal', function()
end)
it("in normal-mode :split does not move cursor", function()
- execute([[terminal while true; do echo foo; sleep .1; done]])
+ feed_command([[terminal while true; do echo foo; sleep .1; done]])
helpers.feed([[<C-\><C-N>M]]) -- move cursor away from last line
wait()
eq(3, eval("line('$')")) -- window height
eq(2, eval("line('.')")) -- cursor is in the middle
- execute('vsplit')
+ feed_command('vsplit')
eq(2, eval("line('.')")) -- cursor stays where we put it
- execute('split')
+ feed_command('split')
eq(2, eval("line('.')")) -- cursor stays where we put it
end)
@@ -65,7 +65,7 @@ describe(':terminal (with fake shell)', function()
-- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints
-- the {cmd} and exits immediately .
local function terminal_with_fake_shell(cmd)
- execute("terminal "..(cmd and cmd or ""))
+ feed_command("terminal "..(cmd and cmd or ""))
end
it('with no argument, acts like termopen()', function()
@@ -157,7 +157,7 @@ describe(':terminal (with fake shell)', function()
end)
it('works with findfile()', function()
- execute('terminal')
+ feed_command('terminal')
eq('term://', string.match(eval('bufname("%")'), "^term://"))
eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")'))
end)
@@ -173,7 +173,7 @@ describe(':terminal (with fake shell)', function()
]])
eq('term://', string.match(eval('bufname("%")'), "^term://"))
helpers.feed([[<C-\><C-N>]])
- execute([[find */shadacat.py]])
+ feed_command([[find */shadacat.py]])
eq('scripts/shadacat.py', eval('bufname("%")'))
end)
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 934c01e3bf..3b04d17705 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(nil)
local Screen = require('test.functional.ui.screen')
local nvim_dir = helpers.nvim_dir
-local execute, nvim = helpers.execute, helpers.nvim
+local feed_command, nvim = helpers.feed_command, helpers.nvim
local function feed_data(data)
nvim('set_var', 'term_data', data)
@@ -58,15 +58,15 @@ local function screen_setup(extra_rows, command, cols)
screen:attach({rgb=false})
- execute('enew | call termopen('..command..')')
+ feed_command('enew | call termopen('..command..')')
nvim('input', '<CR>')
local vim_errmsg = nvim('eval', 'v:errmsg')
if vim_errmsg and "" ~= vim_errmsg then
error(vim_errmsg)
end
- execute('setlocal scrollback=10')
- execute('startinsert')
+ feed_command('setlocal scrollback=10')
+ feed_command('startinsert')
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
-- feeding termcodes to control the display and asserting by screen:expect.
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 0fe463401e..62fabc559c 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local nvim_dir, execute = helpers.nvim_dir, helpers.execute
+local nvim_dir, command = helpers.nvim_dir, helpers.command
local eq, eval = helpers.eq, helpers.eval
if helpers.pending_win32(pending) then return end
@@ -27,7 +27,7 @@ describe('terminal window highlighting', function()
[11] = {background = 11},
})
screen:attach({rgb=false})
- execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
+ command('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
screen:expect([[
tty ready |
{10: } |
@@ -130,7 +130,7 @@ describe('terminal window highlighting with custom palette', function()
})
screen:attach({rgb=true})
nvim('set_var', 'terminal_color_3', '#123456')
- execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
+ command('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
screen:expect([[
tty ready |
{7: } |
@@ -164,9 +164,9 @@ describe('synIDattr()', function()
before_each(function()
clear()
screen = Screen.new(50, 7)
- execute('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black')
+ command('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black')
-- Salmon #fa8072 Maroon #800000
- execute('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon')
+ command('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon')
end)
it('returns cterm-color if RGB-capable UI is _not_ attached', function()
@@ -213,8 +213,8 @@ describe('fg/bg special colors', function()
before_each(function()
clear()
screen = Screen.new(50, 7)
- execute('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black')
- execute('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg')
+ command('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black')
+ command('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg')
end)
it('resolve to "Normal" values', function()
@@ -251,7 +251,7 @@ describe('fg/bg special colors', function()
screen:attach({rgb=true})
local new_guibg = '#282c34'
local new_guifg = '#abb2bf'
- execute('highlight Normal guifg='..new_guifg..' guibg='..new_guibg)
+ command('highlight Normal guifg='..new_guifg..' guibg='..new_guibg)
eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")'))
eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")'))
eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")'))
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 4ead288a19..32f25d4086 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -2,7 +2,7 @@ local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
-local feed, nvim_dir, execute = helpers.feed, helpers.nvim_dir, helpers.execute
+local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command
local eval = helpers.eval
local command = helpers.command
local wait = helpers.wait
@@ -339,7 +339,7 @@ describe('terminal prints more lines than the screen height and exits', function
clear()
local screen = Screen.new(30, 7)
screen:attach({rgb=false})
- execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert')
+ feed_command('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert')
wait()
screen:expect([[
line6 |
@@ -451,7 +451,7 @@ describe("'scrollback' option", function()
it(':setlocal in a normal buffer is an error', function()
command('new')
- execute('setlocal scrollback=42')
+ feed_command('setlocal scrollback=42')
feed('<CR>')
eq('E474:', string.match(eval("v:errmsg"), "E%d*:"))
eq(-1, curbufmeths.get_option('scrollback'))
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 90051b8cd5..fb8a61d10d 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local feed = thelpers.feed_data
-local execute = helpers.execute
+local feed_command = helpers.feed_command
local nvim_dir = helpers.nvim_dir
if helpers.pending_win32(pending) then return end
@@ -59,7 +59,7 @@ describe('tui', function()
it('interprets leading <Esc> byte as ALT modifier in normal-mode', function()
local keys = 'dfghjkl'
for c in keys:gmatch('.') do
- execute('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
+ feed_command('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
feed('\027'..c)
end
screen:expect([[
@@ -152,7 +152,7 @@ describe('tui', function()
end)
it('can handle arbitrarily long bursts of input', function()
- execute('set ruler')
+ feed_command('set ruler')
local t = {}
for i = 1, 3000 do
t[i] = 'item ' .. tostring(i)
@@ -200,8 +200,8 @@ 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_command('autocmd FocusGained * echo "gained"')
+ feed_command('autocmd FocusLost * echo "lost"')
end)
it('can handle focus events in normal mode', function()
@@ -229,7 +229,7 @@ describe('tui focus event handling', function()
end)
it('can handle focus events in insert mode', function()
- execute('set noshowmode')
+ feed_command('set noshowmode')
feed('i')
feed('\027[I')
screen:expect([[
@@ -278,10 +278,10 @@ 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_command('set shell='..nvim_dir..'/shell-test')
+ feed_command('set laststatus=0')
+ feed_command('set noshowmode')
+ feed_command('terminal')
feed('\027[I')
screen:expect([[
ready $ |
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index d3386a641e..4867e0d9fa 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear = helpers.clear
local feed, nvim = helpers.feed, helpers.nvim
-local execute = helpers.execute
+local feed_command = helpers.feed_command
if helpers.pending_win32(pending) then return end
@@ -26,7 +26,7 @@ describe('terminal', function()
it('resets its size when entering terminal window', function()
feed('<c-\\><c-n>')
- execute('2split')
+ feed_command('2split')
screen:expect([[
rows: 2, cols: 50 |
{2:^ } |
@@ -39,7 +39,7 @@ describe('terminal', function()
========== |
:2split |
]])
- execute('wincmd p')
+ feed_command('wincmd p')
screen:expect([[
tty ready |
rows: 2, cols: 50 |
@@ -52,7 +52,7 @@ describe('terminal', function()
========== |
:wincmd p |
]])
- execute('wincmd p')
+ feed_command('wincmd p')
screen:expect([[
rows: 2, cols: 50 |
{2:^ } |