diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 13:11:28 +0000 |
|---|---|---|
| committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 17:53:27 +0000 |
| commit | 4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (patch) | |
| tree | 0cbb2cf8dac8b4f43109dc6f7a4051dfbea23f12 /test/functional/terminal | |
| parent | c30f2e3182e3b50e7c03932027ac55edfc8ada4a (diff) | |
| download | rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.gz rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.bz2 rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.zip | |
test: normalise nvim bridge functions
- remove helpers.cur*meths
- remove helpers.nvim
Diffstat (limited to 'test/functional/terminal')
| -rw-r--r-- | test/functional/terminal/altscreen_spec.lua | 8 | ||||
| -rw-r--r-- | test/functional/terminal/buffer_spec.lua | 8 | ||||
| -rw-r--r-- | test/functional/terminal/cursor_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/terminal/edit_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 35 | ||||
| -rw-r--r-- | test/functional/terminal/helpers.lua | 22 | ||||
| -rw-r--r-- | test/functional/terminal/highlight_spec.lua | 5 | ||||
| -rw-r--r-- | test/functional/terminal/mouse_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 21 |
9 files changed, 58 insertions, 59 deletions
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua index f626a463c5..3c41a68eda 100644 --- a/test/functional/terminal/altscreen_spec.lua +++ b/test/functional/terminal/altscreen_spec.lua @@ -1,6 +1,6 @@ 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 clear, eq, meths = helpers.clear, helpers.eq, helpers.meths local feed = helpers.feed local feed_data = thelpers.feed_data local enter_altscreen = thelpers.enter_altscreen @@ -42,7 +42,7 @@ describe(':terminal altscreen', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(10, curbuf('line_count')) + eq(10, meths.nvim_buf_line_count(0)) end) it('wont clear lines already in the scrollback', function() @@ -107,7 +107,7 @@ describe(':terminal altscreen', function() end) it('wont modify line count', function() - eq(10, curbuf('line_count')) + eq(10, meths.nvim_buf_line_count(0)) end) it('wont modify lines in the scrollback', function() @@ -144,7 +144,7 @@ describe(':terminal altscreen', function() rows: 4, cols: 50 | | ]]) - eq(9, curbuf('line_count')) + eq(9, meths.nvim_buf_line_count(0)) end) describe('and after exit', function() diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 541812b4be..7029b81de0 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 Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local assert_alive = helpers.assert_alive -local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim +local feed, clear = helpers.feed, helpers.clear local poke_eventloop = helpers.poke_eventloop local nvim_prog = helpers.nvim_prog local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source @@ -92,12 +92,12 @@ describe(':terminal buffer', function() end) it('does not create swap files', function() - local swapfile = nvim('exec', 'swapname', true):gsub('\n', '') + local swapfile = meths.nvim_exec('swapname', true):gsub('\n', '') eq(nil, io.open(swapfile)) end) it('does not create undofiles files', function() - local undofile = nvim('eval', 'undofile(bufname("%"))') + local undofile = meths.nvim_eval('undofile(bufname("%"))') eq(nil, io.open(undofile)) end) end) @@ -172,7 +172,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_value', 'statusline', '==========', {}) + meths.nvim_set_option_value('statusline', '==========', {}) -- Save the buffer number of the terminal for later testing. local tbuf = eval('bufnr("%")') diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index a818f8139c..73fd97203e 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -1,7 +1,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 feed, clear = helpers.feed, helpers.clear local testprg, command = helpers.testprg, helpers.command local eq, eval = helpers.eq, helpers.eval local matches = helpers.matches @@ -118,8 +118,8 @@ describe('cursor with customized highlighting', function() before_each(function() clear() - nvim('command', 'highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE') - nvim('command', 'highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE') + command('highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE') + command('highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE') screen = Screen.new(50, 7) screen:set_default_attr_ids({ [1] = { foreground = 45, background = 46 }, diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index 4f462b9e5b..754a681cff 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -1,8 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local screen = require('test.functional.ui.screen') -local curbufmeths = helpers.curbufmeths -local curwinmeths = helpers.curwinmeths local testprg = helpers.testprg local command = helpers.command local funcs = helpers.funcs @@ -48,7 +46,7 @@ describe(':edit term://*', function() command('edit term://foobar') local bufcontents = {} - local winheight = curwinmeths.get_height() + local winheight = meths.nvim_win_get_height(0) local buf_cont_start = rep - sb - winheight + 2 for i = buf_cont_start, (rep - 1) do bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i) @@ -65,6 +63,6 @@ describe(':edit term://*', function() exp_screen = exp_screen .. (' '):rep(columns) .. '|\n' scr:expect(exp_screen) - eq(bufcontents, curbufmeths.get_lines(0, -1, true)) + eq(bufcontents, meths.nvim_buf_get_lines(0, 0, -1, true)) end) end) diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 68d206c177..266a34feea 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -1,11 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local assert_alive = helpers.assert_alive -local clear, poke_eventloop, nvim = helpers.clear, helpers.poke_eventloop, helpers.nvim +local clear, poke_eventloop = helpers.clear, helpers.poke_eventloop local testprg, source, eq = helpers.testprg, helpers.source, helpers.eq local feed = helpers.feed local feed_command, eval = helpers.feed_command, helpers.eval local funcs = helpers.funcs +local meths = helpers.meths local retry = helpers.retry local ok = helpers.ok local command = helpers.command @@ -104,30 +105,30 @@ describe(':terminal', function() it('nvim_get_mode() in :terminal', function() command('terminal') - eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode()) feed('i') - eq({ blocking = false, mode = 't' }, nvim('get_mode')) + eq({ blocking = false, mode = 't' }, meths.nvim_get_mode()) feed([[<C-\><C-N>]]) - eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode()) end) it(':stopinsert RPC request exits terminal-mode #7807', function() command('terminal') feed('i[tui] insert-mode') - eq({ blocking = false, mode = 't' }, nvim('get_mode')) + eq({ blocking = false, mode = 't' }, meths.nvim_get_mode()) command('stopinsert') feed('<Ignore>') -- Add input to separate two RPC requests - eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode()) end) it(":stopinsert in normal mode doesn't break insert mode #9889", function() command('terminal') - eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode()) command('stopinsert') feed('<Ignore>') -- Add input to separate two RPC requests - eq({ blocking = false, mode = 'nt' }, nvim('get_mode')) + eq({ blocking = false, mode = 'nt' }, meths.nvim_get_mode()) feed('a') - eq({ blocking = false, mode = 't' }, nvim('get_mode')) + eq({ blocking = false, mode = 't' }, meths.nvim_get_mode()) end) it('switching to terminal buffer in Insert mode goes to Terminal mode #7164', function() @@ -138,9 +139,9 @@ describe(':terminal', function() command('autocmd InsertLeave * let g:events += ["InsertLeave"]') command('autocmd TermEnter * let g:events += ["TermEnter"]') command('inoremap <F2> <Cmd>wincmd p<CR>') - eq({ blocking = false, mode = 'i' }, nvim('get_mode')) + eq({ blocking = false, mode = 'i' }, meths.nvim_get_mode()) feed('<F2>') - eq({ blocking = false, mode = 't' }, nvim('get_mode')) + eq({ blocking = false, mode = 't' }, meths.nvim_get_mode()) eq({ 'InsertLeave', 'TermEnter' }, eval('g:events')) end) end) @@ -158,9 +159,9 @@ local function test_terminal_with_fake_shell(backslash) clear() screen = Screen.new(50, 4) screen:attach({ rgb = false }) - nvim('set_option_value', 'shell', shell_path, {}) - nvim('set_option_value', 'shellcmdflag', 'EXE', {}) - nvim('set_option_value', 'shellxquote', '', {}) + meths.nvim_set_option_value('shell', shell_path, {}) + meths.nvim_set_option_value('shellcmdflag', 'EXE', {}) + meths.nvim_set_option_value('shellxquote', '', {}) end) it('with no argument, acts like termopen()', function() @@ -177,7 +178,7 @@ local function test_terminal_with_fake_shell(backslash) end) it("with no argument, and 'shell' is set to empty string", function() - nvim('set_option_value', 'shell', '', {}) + meths.nvim_set_option_value('shell', '', {}) feed_command('terminal') screen:expect([[ ^ | @@ -187,7 +188,7 @@ local function test_terminal_with_fake_shell(backslash) end) it("with no argument, but 'shell' has arguments, acts like termopen()", function() - nvim('set_option_value', 'shell', shell_path .. ' INTERACT', {}) + meths.nvim_set_option_value('shell', shell_path .. ' INTERACT', {}) feed_command('terminal') screen:expect([[ ^interact $ | @@ -208,7 +209,7 @@ local function test_terminal_with_fake_shell(backslash) end) it("executes a given command through the shell, when 'shell' has arguments", function() - nvim('set_option_value', 'shell', shell_path .. ' -t jeff', {}) + meths.nvim_set_option_value('shell', shell_path .. ' -t jeff', {}) command('set shellxquote=') -- win: avoid extra quotes feed_command('terminal echo hi') screen:expect([[ diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua index babc2337fa..59af0ab167 100644 --- a/test/functional/terminal/helpers.lua +++ b/test/functional/terminal/helpers.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers')(nil) local Screen = require('test.functional.ui.screen') local testprg = helpers.testprg local exec_lua = helpers.exec_lua -local nvim = helpers.nvim +local meths = helpers.meths local nvim_prog = helpers.nvim_prog local function feed_data(data) @@ -89,8 +89,8 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts) command = command and command or default_command cols = cols and cols or 50 - nvim('command', 'highlight TermCursor cterm=reverse') - nvim('command', 'highlight TermCursorNC ctermbg=11') + meths.nvim_command('highlight TermCursor cterm=reverse') + meths.nvim_command('highlight TermCursorNC ctermbg=11') local screen = Screen.new(cols, 7 + extra_rows) screen:set_default_attr_ids({ @@ -113,17 +113,17 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts) screen:attach(screen_opts or { rgb = false }) - nvim('command', 'enew') - nvim('call_function', 'termopen', { command, env and { env = env } or nil }) - nvim('input', '<CR>') - local vim_errmsg = nvim('eval', 'v:errmsg') + meths.nvim_command('enew') + meths.nvim_call_function('termopen', { command, env and { env = env } or nil }) + meths.nvim_input('<CR>') + local vim_errmsg = meths.nvim_eval('v:errmsg') if vim_errmsg and '' ~= vim_errmsg then error(vim_errmsg) end - nvim('command', 'setlocal scrollback=10') - nvim('command', 'startinsert') - nvim('input', '<Ignore>') -- Add input to separate two RPC requests + meths.nvim_command('setlocal scrollback=10') + meths.nvim_command('startinsert') + meths.nvim_input('<Ignore>') -- Add input to separate two RPC requests -- 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. @@ -147,7 +147,7 @@ local function screen_setup(extra_rows, command, cols, env, screen_opts) screen:expect(table.concat(expected, '|\n') .. '|') else -- This eval also acts as a poke_eventloop(). - if 0 == nvim('eval', "exists('b:terminal_job_id')") then + if 0 == meths.nvim_eval("exists('b:terminal_job_id')") then error('terminal job failed to start') end end diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 951a0f6c65..a8e0f1ac27 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -1,7 +1,8 @@ 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 feed, clear = helpers.feed, helpers.clear +local meths = helpers.meths local testprg, command = helpers.testprg, helpers.command local nvim_prog_abs = helpers.nvim_prog_abs local eq, eval = helpers.eq, helpers.eval @@ -250,7 +251,7 @@ describe(':terminal highlight with custom palette', function() [9] = { bold = true }, }) screen:attach({ rgb = true }) - nvim('set_var', 'terminal_color_3', '#123456') + meths.nvim_set_var('terminal_color_3', '#123456') command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) feed('i') screen:expect([[ diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index 65d0c8f854..e98b04090c 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval -local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command +local feed, meths, command = helpers.feed, helpers.meths, helpers.command local feed_data = thelpers.feed_data local is_os = helpers.is_os local skip = helpers.skip @@ -11,7 +11,7 @@ describe(':terminal mouse', function() before_each(function() clear() - nvim('set_option_value', 'statusline', '==========', {}) + meths.nvim_set_option_value('statusline', '==========', {}) command('highlight StatusLine cterm=NONE') command('highlight StatusLineNC cterm=NONE') command('highlight VertSplit cterm=NONE') @@ -514,7 +514,7 @@ describe(':terminal mouse', function() end) it('handles terminal size when switching buffers', function() - nvim('set_option_value', 'hidden', true, {}) + meths.nvim_set_option_value('hidden', true, {}) feed('<c-\\><c-n><c-w><c-w>') screen:expect([[ {7: 27 }line │line30 | diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 7c1da6b32b..bd58ef0b0a 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -1,14 +1,13 @@ 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 clear, eq = helpers.clear, helpers.eq local feed, testprg = helpers.feed, helpers.testprg local eval = helpers.eval local command = helpers.command local poke_eventloop = helpers.poke_eventloop local retry = helpers.retry local meths = helpers.meths -local nvim = helpers.nvim local feed_data = thelpers.feed_data local pcall_err = helpers.pcall_err local exec_lua = helpers.exec_lua @@ -86,7 +85,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, curbuf('line_count')) + eq(7, meths.nvim_buf_line_count(0)) end) describe('and then 3 more lines are printed', function() @@ -170,7 +169,7 @@ describe(':terminal scrollback', function() {2:^ } | | ]]) - eq(8, curbuf('line_count')) + eq(8, meths.nvim_buf_line_count(0)) feed([[3k]]) screen:expect([[ ^line4 | @@ -204,7 +203,7 @@ describe(':terminal scrollback', function() | {3:-- TERMINAL --} | ]]) - eq(4, curbuf('line_count')) + eq(4, meths.nvim_buf_line_count(0)) end it('will delete the last two empty lines', will_delete_last_two_lines) @@ -222,7 +221,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(4, curbuf('line_count')) + eq(4, meths.nvim_buf_line_count(0)) feed('<c-\\><c-n>gg') screen:expect([[ ^tty ready | @@ -261,7 +260,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, curbuf('line_count')) + eq(7, meths.nvim_buf_line_count(0)) end) describe('and the height is increased by 1', function() @@ -287,7 +286,7 @@ describe(':terminal scrollback', function() describe('and then by 3', function() before_each(function() pop_then_push() - eq(8, curbuf('line_count')) + eq(8, meths.nvim_buf_line_count(0)) screen:try_resize(screen._width, screen._height + 3) end) @@ -302,7 +301,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(9, curbuf('line_count')) + eq(9, meths.nvim_buf_line_count(0)) feed('<c-\\><c-n>gg') screen:expect([[ ^tty ready | @@ -342,7 +341,7 @@ describe(':terminal scrollback', function() ]]) -- since there's an empty line after the cursor, the buffer line -- count equals the terminal screen height - eq(11, curbuf('line_count')) + eq(11, meths.nvim_buf_line_count(0)) end) end) end) @@ -381,7 +380,7 @@ describe("'scrollback' option", function() end) local function set_fake_shell() - nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) + meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) end local function expect_lines(expected, epsilon) |