diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
| commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
| tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /test/functional/ex_cmds | |
| parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
| parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
| download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip | |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/ex_cmds')
40 files changed, 523 insertions, 394 deletions
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua index 5eb8d49c74..80fdcb3134 100644 --- a/test/functional/ex_cmds/append_spec.lua +++ b/test/functional/ex_cmds/append_spec.lua @@ -1,15 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) - -local eq = helpers.eq -local dedent = helpers.dedent -local exec = helpers.exec -local feed = helpers.feed -local clear = helpers.clear -local fn = helpers.fn -local command = helpers.command -local api = helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local eq = t.eq +local dedent = t.dedent +local exec = n.exec +local feed = n.feed +local clear = n.clear +local fn = n.fn +local command = n.command +local api = n.api + local cmdtest = function(cmd, prep, ret1) describe(':' .. cmd, function() before_each(function() diff --git a/test/functional/ex_cmds/arg_spec.lua b/test/functional/ex_cmds/arg_spec.lua index 810b001ec0..9b89823dcc 100644 --- a/test/functional/ex_cmds/arg_spec.lua +++ b/test/functional/ex_cmds/arg_spec.lua @@ -1,7 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq, command, fn = helpers.eq, helpers.command, helpers.fn -local ok = helpers.ok -local clear = helpers.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, command, fn = t.eq, n.command, n.fn +local ok = t.ok +local matches = t.matches +local clear = n.clear describe(':argument', function() before_each(function() @@ -10,19 +13,19 @@ describe(':argument', function() it('does not restart :terminal buffer', function() command('terminal') - helpers.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) command('argadd') - helpers.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) local bufname_before = fn.bufname('%') local bufnr_before = fn.bufnr('%') - helpers.ok(nil ~= string.find(bufname_before, '^term://')) -- sanity + matches('^term://', bufname_before) -- sanity command('argument 1') - helpers.feed([[<C-\><C-N>]]) + n.feed([[<C-\><C-N>]]) local bufname_after = fn.bufname('%') local bufnr_after = fn.bufnr('%') - eq('[' .. bufname_before .. ']', helpers.eval('trim(execute("args"))')) + eq('[' .. bufname_before .. ']', n.eval('trim(execute("args"))')) ok(fn.line('$') > 1) eq(bufname_before, bufname_after) eq(bufnr_before, bufnr_after) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index 1815c672dc..0f95f2aca4 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -1,16 +1,17 @@ -- Specs for :cd, :tcd, :lcd and getcwd() -local helpers = require('test.functional.helpers')(after_each) - -local eq = helpers.eq -local call = helpers.call -local clear = helpers.clear -local command = helpers.command -local exc_exec = helpers.exc_exec -local pathsep = helpers.get_pathsep() -local skip = helpers.skip -local is_os = helpers.is_os -local mkdir = helpers.mkdir +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq = t.eq +local call = n.call +local clear = n.clear +local command = n.command +local exc_exec = n.exc_exec +local pathsep = n.get_pathsep() +local skip = t.skip +local is_os = t.is_os +local mkdir = t.mkdir -- These directories will be created for testing local directories = { @@ -289,14 +290,14 @@ describe('getcwd()', function() end) after_each(function() - helpers.rmdir(directories.global) + n.rmdir(directories.global) end) it('returns empty string if working directory does not exist', function() skip(is_os('win')) command('cd ' .. directories.global) command("call delete('../" .. directories.global .. "', 'd')") - eq('', helpers.eval('getcwd()')) + eq('', n.eval('getcwd()')) end) it("works with 'autochdir' after local directory was set (#9892)", function() diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua index cb7d7340e2..6c1ac8eae5 100644 --- a/test/functional/ex_cmds/cmd_map_spec.lua +++ b/test/functional/ex_cmds/cmd_map_spec.lua @@ -1,16 +1,18 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local feed = helpers.feed -local eq = helpers.eq -local expect = helpers.expect -local eval = helpers.eval -local fn = helpers.fn -local insert = helpers.insert -local write_file = helpers.write_file -local exc_exec = helpers.exc_exec -local command = helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear = n.clear +local feed = n.feed +local eq = t.eq +local expect = n.expect +local eval = n.eval +local fn = n.fn +local insert = n.insert +local write_file = t.write_file +local exc_exec = n.exc_exec +local command = n.command + describe('mappings with <Cmd>', function() local screen local tmpfile = 'X_ex_cmds_cmd_map' @@ -505,7 +507,7 @@ describe('mappings with <Cmd>', function() feed('"bd<F7>') expect([[ soest text]]) - eq(fn.getreg('b', 1, 1), { 'me short lines', 'of t' }) + eq({ 'me short lines', 'of t' }, fn.getreg('b', 1, 1)) -- startinsert aborts operator feed('d<F8>') @@ -561,7 +563,7 @@ describe('mappings with <Cmd>', function() of stuff test text]]) feed('<F5>') - eq(fn.getreg('a', 1, 1), { 'deed some short little lines', 'of stuff t' }) + eq({ 'deed some short little lines', 'of stuff t' }, fn.getreg('a', 1, 1)) -- still in insert screen:expect([[ diff --git a/test/functional/ex_cmds/debug_spec.lua b/test/functional/ex_cmds/debug_spec.lua index 85327c87e6..ebb3cdd38a 100644 --- a/test/functional/ex_cmds/debug_spec.lua +++ b/test/functional/ex_cmds/debug_spec.lua @@ -1,7 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = helpers.feed -local clear = helpers.clear + +local feed = n.feed +local clear = n.clear describe(':debug', function() local screen diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index fc7714d16b..b6068a86db 100644 --- a/test/functional/ex_cmds/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -1,13 +1,15 @@ -local helpers = require('test.functional.helpers')(after_each) -local assert_alive = helpers.assert_alive -local clear, source = helpers.clear, helpers.source -local api = helpers.api -local insert = helpers.insert -local eq, next_msg = helpers.eq, helpers.next_msg -local exc_exec = helpers.exc_exec -local exec_lua = helpers.exec_lua -local command = helpers.command -local eval = helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local assert_alive = n.assert_alive +local clear, source = n.clear, n.source +local api = n.api +local insert = n.insert +local eq, next_msg = t.eq, n.next_msg +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local command = n.command +local eval = n.eval describe('Vimscript dictionary notifications', function() local channel diff --git a/test/functional/ex_cmds/digraphs_spec.lua b/test/functional/ex_cmds/digraphs_spec.lua index 24b6f7c53b..fde25c028f 100644 --- a/test/functional/ex_cmds/digraphs_spec.lua +++ b/test/functional/ex_cmds/digraphs_spec.lua @@ -1,9 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear = n.clear +local command = n.command +local feed = n.feed + describe(':digraphs', function() local screen before_each(function() diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua index cbda5aac98..54ddd79a35 100644 --- a/test/functional/ex_cmds/drop_spec.lua +++ b/test/functional/ex_cmds/drop_spec.lua @@ -1,7 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local command = helpers.command +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command + +local command = n.command +local clear, feed, feed_command = n.clear, n.feed, n.feed_command +local exec = n.exec describe(':drop', function() local screen @@ -16,7 +18,7 @@ describe(':drop', function() [2] = { reverse = true }, [3] = { bold = true }, }) - command('set laststatus=2 shortmess-=F') + command('set nohidden laststatus=2 shortmess-=F') end) it('works like :e when called with only one window open', function() @@ -43,7 +45,6 @@ describe(':drop', function() end) it("splits off a new window when a buffer can't be abandoned", function() - command('set nohidden') feed_command('edit tmp1') feed_command('vsplit') feed_command('edit tmp2') @@ -59,4 +60,20 @@ describe(':drop', function() "tmp3" [New] | ]]) end) + + -- oldtest: Test_drop_modified_file() + it('does not cause E37 with modified same file', function() + exec([[ + edit Xdrop_modified.txt + call setline(1, 'The quick brown fox jumped over the lazy dogs') + ]]) + feed_command('drop Xdrop_modified.txt') + screen:expect([[ + ^The quick brown fox jumped over the| + lazy dogs | + {0:~ }|*6 + {1:Xdrop_modified.txt [+] }| + :drop Xdrop_modified.txt | + ]]) + end) end) diff --git a/test/functional/ex_cmds/echo_spec.lua b/test/functional/ex_cmds/echo_spec.lua index e9176a6204..2f0bcb4d9d 100644 --- a/test/functional/ex_cmds/echo_spec.lua +++ b/test/functional/ex_cmds/echo_spec.lua @@ -1,17 +1,18 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq +local eq = t.eq local NIL = vim.NIL -local eval = helpers.eval -local clear = helpers.clear -local api = helpers.api -local fn = helpers.fn -local source = helpers.source -local dedent = helpers.dedent -local command = helpers.command -local exc_exec = helpers.exc_exec -local exec_capture = helpers.exec_capture -local matches = helpers.matches +local eval = n.eval +local clear = n.clear +local api = n.api +local fn = n.fn +local source = n.source +local dedent = t.dedent +local command = n.command +local exc_exec = n.exc_exec +local exec_capture = n.exec_capture +local matches = t.matches describe(':echo :echon :echomsg :echoerr', function() local fn_tbl = { 'String', 'StringN', 'StringMsg', 'StringErr' } @@ -255,7 +256,7 @@ describe(':echo :echon :echomsg :echoerr', function() eval('add(l, l)') -- Regression: the below line used to crash (add returns original list and -- there was error in dumping partials). Tested explicitly in - -- test/unit/api/private_helpers_spec.lua. + -- test/unit/api/private_t_spec.lua. eval('add(l, function("Test1", l))') eq( dedent( @@ -349,8 +350,8 @@ describe(':echo :echon :echomsg :echoerr', function() end) describe('used to represent special values', function() - local function chr(n) - return ('%c'):format(n) + local function chr(_n) + return ('%c'):format(_n) end local function ctrl(c) return ('%c'):format(c:upper():byte() - 0x40) diff --git a/test/functional/ex_cmds/edit_spec.lua b/test/functional/ex_cmds/edit_spec.lua index b927fa418a..39849a202f 100644 --- a/test/functional/ex_cmds/edit_spec.lua +++ b/test/functional/ex_cmds/edit_spec.lua @@ -1,8 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local eq, command, fn = helpers.eq, helpers.command, helpers.fn -local ok = helpers.ok -local clear = helpers.clear -local feed = helpers.feed +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq, command, fn = t.eq, n.command, n.fn +local ok = t.ok +local matches = t.matches +local clear = n.clear +local feed = n.feed describe(':edit', function() before_each(function() @@ -14,7 +17,7 @@ describe(':edit', function() feed([[<C-\><C-N>]]) local bufname_before = fn.bufname('%') local bufnr_before = fn.bufnr('%') - helpers.ok(nil ~= string.find(bufname_before, '^term://')) -- sanity + matches('^term://', bufname_before) -- sanity command('edit') diff --git a/test/functional/ex_cmds/encoding_spec.lua b/test/functional/ex_cmds/encoding_spec.lua index 8953fb8eaf..6b882253b9 100644 --- a/test/functional/ex_cmds/encoding_spec.lua +++ b/test/functional/ex_cmds/encoding_spec.lua @@ -1,6 +1,8 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, feed_command, feed = helpers.clear, helpers.feed_command, helpers.feed -local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, feed = n.clear, n.feed_command, n.feed +local eq, neq, eval = t.eq, t.neq, n.eval describe('&encoding', function() before_each(function() diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua index d16a52ee62..20ebb2dedb 100644 --- a/test/functional/ex_cmds/excmd_spec.lua +++ b/test/functional/ex_cmds/excmd_spec.lua @@ -1,10 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local command = helpers.command -local eq = helpers.eq -local clear = helpers.clear -local fn = helpers.fn -local pcall_err = helpers.pcall_err -local assert_alive = helpers.assert_alive +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local eq = t.eq +local clear = n.clear +local fn = n.fn +local pcall_err = t.pcall_err +local assert_alive = n.assert_alive describe('Ex cmds', function() before_each(function() diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua index a48c408600..0c51f1c17b 100644 --- a/test/functional/ex_cmds/file_spec.lua +++ b/test/functional/ex_cmds/file_spec.lua @@ -1,10 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local fn = helpers.fn -local rmdir = helpers.rmdir -local mkdir = helpers.mkdir +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local eq = t.eq +local fn = n.fn +local rmdir = n.rmdir +local mkdir = t.mkdir describe(':file', function() local swapdir = vim.uv.cwd() .. '/Xtest-file_spec' diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua index bf81ba2137..f7d0f43c62 100644 --- a/test/functional/ex_cmds/grep_spec.lua +++ b/test/functional/ex_cmds/grep_spec.lua @@ -1,6 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, feed_command, feed, ok, eval = - helpers.clear, helpers.feed_command, helpers.feed, helpers.ok, helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, feed_command, feed, ok, eval = n.clear, n.feed_command, n.feed, t.ok, n.eval describe(':grep', function() before_each(clear) diff --git a/test/functional/ex_cmds/help_spec.lua b/test/functional/ex_cmds/help_spec.lua index cee33de1a6..f0a7bea7e4 100644 --- a/test/functional/ex_cmds/help_spec.lua +++ b/test/functional/ex_cmds/help_spec.lua @@ -1,19 +1,20 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local fn = helpers.fn -local api = helpers.api -local mkdir = helpers.mkdir -local rmdir = helpers.rmdir -local write_file = helpers.write_file +local clear = n.clear +local command = n.command +local eq = t.eq +local fn = n.fn +local api = n.api +local mkdir = t.mkdir +local rmdir = n.rmdir +local write_file = t.write_file describe(':help', function() before_each(clear) it('window closed makes cursor return to a valid win/buf #9773', function() - helpers.add_builddir_to_rtp() + n.add_builddir_to_rtp() command('help help') eq(1001, fn.win_getid()) command('quit') diff --git a/test/functional/ex_cmds/highlight_spec.lua b/test/functional/ex_cmds/highlight_spec.lua index 897a2997bc..3cb6cc2579 100644 --- a/test/functional/ex_cmds/highlight_spec.lua +++ b/test/functional/ex_cmds/highlight_spec.lua @@ -1,11 +1,13 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) -local eq, command = helpers.eq, helpers.command -local clear = helpers.clear -local eval, exc_exec = helpers.eval, helpers.exc_exec -local exec = helpers.exec -local fn = helpers.fn -local api = helpers.api + +local eq, command = t.eq, n.command +local clear = n.clear +local eval, exc_exec = n.eval, n.exc_exec +local exec = n.exec +local fn = n.fn +local api = n.api describe(':highlight', function() local screen diff --git a/test/functional/ex_cmds/ls_spec.lua b/test/functional/ex_cmds/ls_spec.lua index 5f59402d10..aab53f0634 100644 --- a/test/functional/ex_cmds/ls_spec.lua +++ b/test/functional/ex_cmds/ls_spec.lua @@ -1,12 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed -local api = helpers.api -local testprg = helpers.testprg -local retry = helpers.retry +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local eq = t.eq +local eval = n.eval +local feed = n.feed +local api = n.api +local testprg = n.testprg +local retry = t.retry describe(':ls', function() before_each(function() diff --git a/test/functional/ex_cmds/make_spec.lua b/test/functional/ex_cmds/make_spec.lua index dd47bdec58..d6164cec29 100644 --- a/test/functional/ex_cmds/make_spec.lua +++ b/test/functional/ex_cmds/make_spec.lua @@ -1,10 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eval = helpers.eval -local has_powershell = helpers.has_powershell -local matches = helpers.matches -local api = helpers.api -local testprg = helpers.testprg +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eval = n.eval +local has_powershell = n.has_powershell +local matches = t.matches +local api = n.api +local testprg = n.testprg describe(':make', function() clear() @@ -18,7 +20,7 @@ describe(':make', function() return end before_each(function() - helpers.set_shell_powershell() + n.set_shell_powershell() end) it('captures stderr & non zero exit code #14349', function() diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua index d3b027e6f4..9ef0a8ec2e 100644 --- a/test/functional/ex_cmds/map_spec.lua +++ b/test/functional/ex_cmds/map_spec.lua @@ -1,16 +1,17 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local eq = helpers.eq -local exec = helpers.exec -local exec_capture = helpers.exec_capture -local feed = helpers.feed -local api = helpers.api -local clear = helpers.clear -local command = helpers.command -local expect = helpers.expect -local insert = helpers.insert -local eval = helpers.eval +local eq = t.eq +local exec = n.exec +local exec_capture = n.exec_capture +local feed = n.feed +local api = n.api +local clear = n.clear +local command = n.command +local expect = n.expect +local insert = n.insert +local eval = n.eval describe(':*map', function() before_each(clear) @@ -109,19 +110,19 @@ describe('Screen', function() command('map <expr> x input("> ")') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 | ]]) feed('x') screen:expect([[ | - ~ |*3 + {1:~ }|*3 > ^ | ]]) feed('\n') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 > | ]]) end) @@ -131,20 +132,20 @@ describe('Screen', function() feed('i') screen:expect([[ ^ | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) feed('x') screen:expect([[ | - ~ |*3 + {1:~ }|*3 > ^ | ]]) feed('\n') screen:expect([[ ^ | - ~ |*3 - -- INSERT -- | + {1:~ }|*3 + {5:-- INSERT --} | ]]) end) @@ -153,7 +154,7 @@ describe('Screen', function() feed(':<F2>') screen:expect([[ | - ~ |*3 + {1:~ }|*3 :^ | ]]) end) @@ -181,7 +182,7 @@ describe('Screen', function() one | ^two | three | - [on] | + {9:[on] }| | ]]) end) @@ -191,15 +192,16 @@ describe('Screen', function() command('nmap <expr> <F2> execute("throw 42")') feed('<F2>') screen:expect([[ - |*2 - Error detected while processing : | - E605: Exception not caught: 42 | - Press ENTER or type command to continue^ | + | + {3: }| + {9:Error detected while processing :} | + {9:E605: Exception not caught: 42} | + {6:Press ENTER or type command to continue}^ | ]]) feed('<CR>') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 | ]]) end) @@ -210,32 +212,32 @@ describe('Screen', function() feed(':echo "foo') screen:expect([[ | - ~ |*3 + {1:~ }|*3 :echo "foo^ | ]]) feed('<F2>') screen:expect([[ - | + {3: }| :echo "foo | - Error detected while processing : | - E605: Exception not caught: 42 | + {9:Error detected while processing :} | + {9:E605: Exception not caught: 42} | :echo "foo^ | ]]) feed('"') screen:expect([[ - | + {3: }| :echo "foo | - Error detected while processing : | - E605: Exception not caught: 42 | + {9:Error detected while processing :} | + {9:E605: Exception not caught: 42} | :echo "foo"^ | ]]) feed('\n') screen:expect([[ :echo "foo | - Error detected while processing : | - E605: Exception not caught: 42 | + {9:Error detected while processing :} | + {9:E605: Exception not caught: 42} | foo | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) end) @@ -246,7 +248,7 @@ describe('Screen', function() feed(': nmap a<CR>') screen:expect([[ ^ | - ~ |*3 + {1:~ }|*3 n a b | ]]) end) diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua index bb6ef72787..e73f705a29 100644 --- a/test/functional/ex_cmds/menu_spec.lua +++ b/test/functional/ex_cmds/menu_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, command = helpers.clear, helpers.command -local expect, feed = helpers.expect, helpers.feed -local eq, eval = helpers.eq, helpers.eval -local fn = helpers.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, command = n.clear, n.command +local expect, feed = n.expect, n.feed +local eq, eval = t.eq, n.eval +local fn = n.fn describe(':emenu', function() before_each(function() diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 6f2e0be3d5..9b24854362 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -1,20 +1,21 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local get_pathsep = helpers.get_pathsep -local eq = helpers.eq -local neq = helpers.neq -local fn = helpers.fn -local matches = helpers.matches +local clear = n.clear +local command = n.command +local get_pathsep = n.get_pathsep +local eq = t.eq +local neq = t.neq +local fn = n.fn +local matches = t.matches local pesc = vim.pesc -local rmdir = helpers.rmdir +local rmdir = n.rmdir local sleep = vim.uv.sleep -local api = helpers.api -local skip = helpers.skip -local is_os = helpers.is_os -local mkdir = helpers.mkdir +local api = n.api +local skip = t.skip +local is_os = t.is_os +local mkdir = t.mkdir local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua index de0a4fe0ea..7cc0b1da83 100644 --- a/test/functional/ex_cmds/mkview_spec.lua +++ b/test/functional/ex_cmds/mkview_spec.lua @@ -1,12 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local command = helpers.command -local get_pathsep = helpers.get_pathsep -local eq = helpers.eq -local fn = helpers.fn -local rmdir = helpers.rmdir -local mkdir = helpers.mkdir +local clear = n.clear +local command = n.command +local get_pathsep = n.get_pathsep +local eq = t.eq +local fn = n.fn +local rmdir = n.rmdir +local mkdir = t.mkdir local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec' diff --git a/test/functional/ex_cmds/normal_spec.lua b/test/functional/ex_cmds/normal_spec.lua index 723bfefcf4..ccc649120f 100644 --- a/test/functional/ex_cmds/normal_spec.lua +++ b/test/functional/ex_cmds/normal_spec.lua @@ -1,11 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local fn = helpers.fn -local feed = helpers.feed -local expect = helpers.expect -local eq = helpers.eq -local eval = helpers.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local fn = n.fn +local feed = n.feed +local expect = n.expect +local eq = t.eq +local eval = n.eval before_each(clear) diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index 8d1469f343..927d780181 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -1,13 +1,14 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local expect_exit = helpers.expect_exit -local api, eq, feed_command = helpers.api, helpers.eq, helpers.feed_command -local feed, poke_eventloop = helpers.feed, helpers.poke_eventloop -local ok = helpers.ok -local eval = helpers.eval +local clear = n.clear +local command = n.command +local expect_exit = n.expect_exit +local api, eq, feed_command = n.api, t.eq, n.feed_command +local feed, poke_eventloop = n.feed, n.poke_eventloop +local ok = t.ok +local eval = n.eval local shada_file = 'Xtest.shada' @@ -38,6 +39,7 @@ describe(':oldfiles', function() it('shows most recently used files', function() local screen = Screen.new(100, 5) screen:attach() + screen._default_attr_ids = nil feed_command('edit testfile1') feed_command('edit testfile2') feed_command('wshada') @@ -65,12 +67,12 @@ describe(':oldfiles', function() feed_command('rshada!') local function get_oldfiles(cmd) - local t = eval([[split(execute(']] .. cmd .. [['), "\n")]]) - for i, _ in ipairs(t) do - t[i] = t[i]:gsub('^%d+:%s+', '') + local q = eval([[split(execute(']] .. cmd .. [['), "\n")]]) + for i, _ in ipairs(q) do + q[i] = q[i]:gsub('^%d+:%s+', '') end - table.sort(t) - return t + table.sort(q) + return q end local oldfiles = get_oldfiles('oldfiles') @@ -108,7 +110,7 @@ describe(':browse oldfiles', function() -- Ensure v:oldfiles isn't busted. Since things happen so fast, -- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood). -- Let's verify the contents and the length of v:oldfiles before moving on. - oldfiles = helpers.api.nvim_get_vvar('oldfiles') + oldfiles = n.api.nvim_get_vvar('oldfiles') eq(2, #oldfiles) ok(filename == oldfiles[1] or filename == oldfiles[2]) ok(filename2 == oldfiles[1] or filename2 == oldfiles[2]) diff --git a/test/functional/ex_cmds/print_commands_spec.lua b/test/functional/ex_cmds/print_commands_spec.lua index ba5ec7d2d1..8c164fd41b 100644 --- a/test/functional/ex_cmds/print_commands_spec.lua +++ b/test/functional/ex_cmds/print_commands_spec.lua @@ -1,5 +1,7 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, command, fn = helpers.clear, helpers.eq, helpers.command, helpers.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, command, fn = n.clear, t.eq, n.command, n.fn describe(':z^', function() before_each(clear) diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua index f85dcc60ff..57e5c6b2dc 100644 --- a/test/functional/ex_cmds/profile_spec.lua +++ b/test/functional/ex_cmds/profile_spec.lua @@ -1,14 +1,15 @@ -require('os') +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local uv = vim.uv +require('os') -local helpers = require('test.functional.helpers')(after_each) -local eval = helpers.eval -local command = helpers.command -local eq, neq = helpers.eq, helpers.neq -local tempfile = helpers.tmpname() -local source = helpers.source -local matches = helpers.matches -local read_file = helpers.read_file +local eval = n.eval +local command = n.command +local eq, neq = t.eq, t.neq +local tempfile = t.tmpname() +local source = n.source +local matches = t.matches +local read_file = t.read_file -- tmpname() also creates the file on POSIX systems. Remove it again. -- We just need the name, ignoring any race conditions. @@ -25,10 +26,10 @@ local function assert_file_exists_not(filepath) end describe(':profile', function() - before_each(helpers.clear) + before_each(n.clear) after_each(function() - helpers.expect_exit(command, 'qall!') + n.expect_exit(command, 'qall!') if uv.fs_stat(tempfile).uid ~= nil then os.remove(tempfile) end diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua index 5af0198ffe..3df41b015e 100644 --- a/test/functional/ex_cmds/quickfix_commands_spec.lua +++ b/test/functional/ex_cmds/quickfix_commands_spec.lua @@ -1,15 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local feed = helpers.feed -local eq = helpers.eq -local clear = helpers.clear -local fn = helpers.fn -local command = helpers.command -local exc_exec = helpers.exc_exec -local write_file = helpers.write_file -local api = helpers.api -local source = helpers.source +local feed = n.feed +local eq = t.eq +local clear = n.clear +local fn = n.fn +local command = n.command +local exc_exec = n.exc_exec +local write_file = t.write_file +local api = n.api +local source = n.source local file_base = 'Xtest-functional-ex_cmds-quickfix_commands' diff --git a/test/functional/ex_cmds/quit_spec.lua b/test/functional/ex_cmds/quit_spec.lua index 5a1759dab3..83b1c5a540 100644 --- a/test/functional/ex_cmds/quit_spec.lua +++ b/test/functional/ex_cmds/quit_spec.lua @@ -1,5 +1,6 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear +local n = require('test.functional.testnvim')() + +local clear = n.clear describe(':qa', function() before_each(function() diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua index 4c963c5da7..d69fae11ce 100644 --- a/test/functional/ex_cmds/script_spec.lua +++ b/test/functional/ex_cmds/script_spec.lua @@ -1,15 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq -local neq = helpers.neq -local command = helpers.command -local exec_capture = helpers.exec_capture -local write_file = helpers.write_file -local api = helpers.api -local clear = helpers.clear -local dedent = helpers.dedent -local exc_exec = helpers.exc_exec -local missing_provider = helpers.missing_provider +local eq = t.eq +local neq = t.neq +local command = n.command +local exec_capture = n.exec_capture +local write_file = t.write_file +local api = n.api +local clear = n.clear +local dedent = t.dedent +local exc_exec = n.exc_exec +local missing_provider = n.missing_provider local tmpfile = 'X_ex_cmds_script' diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua index 06de7f23a9..1d1708a41c 100644 --- a/test/functional/ex_cmds/sign_spec.lua +++ b/test/functional/ex_cmds/sign_spec.lua @@ -1,7 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, eq, assert_alive = helpers.clear, helpers.eq, helpers.assert_alive -local command = helpers.command -local api = helpers.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear, eq, assert_alive = n.clear, t.eq, n.assert_alive +local command = n.command +local api = n.api describe('sign', function() before_each(clear) diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 5ce0e395bd..0a6f44fab4 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -1,23 +1,25 @@ -local helpers = require('test.functional.helpers')(after_each) -local command = helpers.command -local insert = helpers.insert -local eq = helpers.eq -local clear = helpers.clear -local api = helpers.api -local feed = helpers.feed -local feed_command = helpers.feed_command -local write_file = helpers.write_file -local tmpname = helpers.tmpname -local exec = helpers.exec -local exc_exec = helpers.exc_exec -local exec_lua = helpers.exec_lua -local eval = helpers.eval -local exec_capture = helpers.exec_capture -local neq = helpers.neq -local matches = helpers.matches -local mkdir = helpers.mkdir -local rmdir = helpers.rmdir -local is_os = helpers.is_os +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local insert = n.insert +local eq = t.eq +local clear = n.clear +local api = n.api +local feed = n.feed +local feed_command = n.feed_command +local write_file = t.write_file +local tmpname = t.tmpname +local exec = n.exec +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local eval = n.eval +local exec_capture = n.exec_capture +local neq = t.neq +local matches = t.matches +local mkdir = t.mkdir +local rmdir = n.rmdir +local is_os = t.is_os describe(':source', function() before_each(function() diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index a6fdb919c5..5bb2a0181e 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -1,29 +1,31 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) + local uv = vim.uv -local eq, eval, expect, exec = helpers.eq, helpers.eval, helpers.expect, helpers.exec -local assert_alive = helpers.assert_alive -local clear = helpers.clear -local command = helpers.command -local feed = helpers.feed -local fn = helpers.fn -local nvim_prog = helpers.nvim_prog -local ok = helpers.ok -local rmdir = helpers.rmdir -local new_argv = helpers.new_argv -local new_pipename = helpers.new_pipename +local eq, eval, expect, exec = t.eq, n.eval, n.expect, n.exec +local assert_alive = n.assert_alive +local clear = n.clear +local command = n.command +local feed = n.feed +local fn = n.fn +local nvim_prog = n.nvim_prog +local ok = t.ok +local rmdir = n.rmdir +local new_argv = n.new_argv +local new_pipename = n.new_pipename local pesc = vim.pesc -local os_kill = helpers.os_kill -local set_session = helpers.set_session -local spawn = helpers.spawn -local async_meths = helpers.async_meths -local expect_msg_seq = helpers.expect_msg_seq -local pcall_err = helpers.pcall_err -local mkdir = helpers.mkdir -local poke_eventloop = helpers.poke_eventloop -local api = helpers.api -local retry = helpers.retry -local write_file = helpers.write_file +local os_kill = n.os_kill +local set_session = n.set_session +local spawn = n.spawn +local async_meths = n.async_meths +local expect_msg_seq = n.expect_msg_seq +local pcall_err = t.pcall_err +local mkdir = t.mkdir +local poke_eventloop = n.poke_eventloop +local api = n.api +local retry = t.retry +local write_file = t.write_file describe(':recover', function() before_each(clear) @@ -110,7 +112,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() end) it('killing TUI process without :preserve #22096', function() - helpers.skip(helpers.is_os('win')) + t.skip(t.is_os('win')) local screen0 = Screen.new() screen0:attach() local child_server = new_pipename() @@ -118,7 +120,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) screen0:expect({ any = pesc('[No Name]') }) -- Wait for the child process to start. - local child_session = helpers.connect(child_server) + local child_session = n.connect(child_server) set_session(child_session) local swappath1 = setup_swapname() set_session(nvim0) @@ -170,6 +172,7 @@ describe('swapfile detection', function() set_session(nvim2) local screen2 = Screen.new(256, 40) screen2:attach() + screen2._default_attr_ids = nil exec(init) command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). diff --git a/test/functional/ex_cmds/syntax_spec.lua b/test/functional/ex_cmds/syntax_spec.lua index ccdd604c55..35b45fe800 100644 --- a/test/functional/ex_cmds/syntax_spec.lua +++ b/test/functional/ex_cmds/syntax_spec.lua @@ -1,8 +1,9 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq -local clear = helpers.clear -local exc_exec = helpers.exc_exec +local eq = t.eq +local clear = n.clear +local exc_exec = n.exc_exec describe(':syntax', function() before_each(clear) diff --git a/test/functional/ex_cmds/trust_spec.lua b/test/functional/ex_cmds/trust_spec.lua index 2997b504fa..76248cf530 100644 --- a/test/functional/ex_cmds/trust_spec.lua +++ b/test/functional/ex_cmds/trust_spec.lua @@ -1,27 +1,28 @@ -local helpers = require('test.functional.helpers')(after_each) - -local eq = helpers.eq -local clear = helpers.clear -local command = helpers.command -local exec_capture = helpers.exec_capture -local matches = helpers.matches -local pathsep = helpers.get_pathsep() -local is_os = helpers.is_os -local fn = helpers.fn +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq = t.eq +local clear = n.clear +local command = n.command +local exec_capture = n.exec_capture +local matches = t.matches +local pathsep = n.get_pathsep() +local is_os = t.is_os +local fn = n.fn describe(':trust', function() local xstate = 'Xstate' setup(function() - helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) + n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim')) end) teardown(function() - helpers.rmdir(xstate) + n.rmdir(xstate) end) before_each(function() - helpers.write_file('test_file', 'test') + t.write_file('test_file', 'test') clear { env = { XDG_STATE_HOME = xstate } } end) @@ -31,37 +32,37 @@ describe(':trust', function() it('trust then deny then remove a file using current buffer', function() local cwd = fn.getcwd() - local hash = fn.sha256(helpers.read_file('test_file')) + local hash = fn.sha256(t.read_file('test_file')) command('edit test_file') matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust')) - local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + local trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust)) matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny')) - trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust)) matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove')) - trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format(''), vim.trim(trust)) end) it('deny then trust then remove a file using current buffer', function() local cwd = fn.getcwd() - local hash = fn.sha256(helpers.read_file('test_file')) + local hash = fn.sha256(t.read_file('test_file')) command('edit test_file') matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny')) - local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + local trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust)) matches('^Allowed ".*test_file" in trust database%.$', exec_capture('trust')) - trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format('%s %s', hash, cwd .. pathsep .. 'test_file'), vim.trim(trust)) matches('^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove')) - trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format(''), vim.trim(trust)) end) @@ -69,14 +70,14 @@ describe(':trust', function() local cwd = fn.getcwd() matches('^Denied ".*test_file" in trust database%.$', exec_capture('trust ++deny test_file')) - local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + local trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format('! %s', cwd .. pathsep .. 'test_file'), vim.trim(trust)) matches( '^Removed ".*test_file" from trust database%.$', exec_capture('trust ++remove test_file') ) - trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust') + trust = t.read_file(fn.stdpath('state') .. pathsep .. 'trust') eq(string.format(''), vim.trim(trust)) end) end) diff --git a/test/functional/ex_cmds/undojoin_spec.lua b/test/functional/ex_cmds/undojoin_spec.lua index 7803906619..06b5973053 100644 --- a/test/functional/ex_cmds/undojoin_spec.lua +++ b/test/functional/ex_cmds/undojoin_spec.lua @@ -1,12 +1,13 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local eq = helpers.eq -local clear = helpers.clear -local insert = helpers.insert -local feed = helpers.feed -local expect = helpers.expect -local feed_command = helpers.feed_command -local exc_exec = helpers.exc_exec +local eq = t.eq +local clear = n.clear +local insert = n.insert +local feed = n.feed +local expect = n.expect +local feed_command = n.feed_command +local exc_exec = n.exc_exec describe(':undojoin command', function() before_each(function() diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua index 7ceb2460d3..0f99552935 100644 --- a/test/functional/ex_cmds/verbose_spec.lua +++ b/test/functional/ex_cmds/verbose_spec.lua @@ -1,11 +1,12 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() -local clear = helpers.clear -local eq = helpers.eq -local exec = helpers.exec -local exec_capture = helpers.exec_capture -local write_file = helpers.write_file -local call_viml_function = helpers.api.nvim_call_function +local clear = n.clear +local eq = t.eq +local exec = n.exec +local exec_capture = n.exec_capture +local write_file = t.write_file +local call_viml_function = n.api.nvim_call_function local function last_set_tests(cmd) local script_location, script_file @@ -15,7 +16,7 @@ local function last_set_tests(cmd) script_file = 'test_verbose.lua' local current_dir = call_viml_function('getcwd', {}) current_dir = call_viml_function('fnamemodify', { current_dir, ':~' }) - script_location = table.concat { current_dir, helpers.get_pathsep(), script_file } + script_location = table.concat { current_dir, n.get_pathsep(), script_file } write_file( script_file, @@ -32,21 +33,30 @@ vim.api.nvim_exec2("augroup test_group\ augroup END\ ", {}) +vim.api.nvim_create_autocmd('FileType', { + group = 'test_group', + pattern = 'cpp', + command = 'setl cindent', +}) + +vim.api.nvim_exec2(':highlight TestHL1 guibg=Blue', {}) +vim.api.nvim_set_hl(0, 'TestHL2', { bg = 'Green' }) + vim.api.nvim_command("command Bdelete :bd") vim.api.nvim_create_user_command("TestCommand", ":echo 'Hello'", {}) -vim.api.nvim_exec ("\ +vim.api.nvim_exec2 ("\ function Close_Window() abort\ wincmd -\ endfunction\ -", false) +", {}) -local ret = vim.api.nvim_exec ("\ +local ret = vim.api.nvim_exec2 ("\ function! s:return80()\ return 80\ endfunction\ let &tw = s:return80()\ -", true) +", {}) ]] ) exec(cmd .. ' ' .. script_file) @@ -109,7 +119,7 @@ n \key1 * :echo "test"<CR> ) end) - it('"Last set" for mapping set by vim.keymap', function() + it('"Last set" for mapping set by vim.keymap.set', function() local result = exec_capture(':verbose map <leader>key2') eq( string.format( @@ -123,7 +133,7 @@ n \key2 * :echo "test"<CR> ) end) - it('"Last set" for autocmd by vim.api.nvim_exec', function() + it('"Last set" for autocmd set by nvim_exec2', function() local result = exec_capture(':verbose autocmd test_group Filetype c') eq( string.format( @@ -138,6 +148,47 @@ test_group FileType ) end) + it('"Last set" for autocmd set by nvim_create_autocmd', function() + local result = exec_capture(':verbose autocmd test_group Filetype cpp') + eq( + string.format( + [[ +--- Autocommands --- +test_group FileType + cpp setl cindent + Last set from %s line 13]], + script_location + ), + result + ) + end) + + it('"Last set" for highlight group set by nvim_exec2', function() + local result = exec_capture(':verbose highlight TestHL1') + eq( + string.format( + [[ +TestHL1 xxx guibg=Blue + Last set from %s line 19]], + script_location + ), + result + ) + end) + + it('"Last set" for highlight group set by nvim_set_hl', function() + local result = exec_capture(':verbose highlight TestHL2') + eq( + string.format( + [[ +TestHL2 xxx guibg=Green + Last set from %s line 20]], + script_location + ), + result + ) + end) + it('"Last set" for command defined by nvim_command', function() if cmd == 'luafile' then pending('nvim_command does not set the script context') @@ -148,7 +199,7 @@ test_group FileType [[ Name Args Address Complete Definition Bdelete 0 :bd - Last set from %s line 13]], + Last set from %s line 22]], script_location ), result @@ -162,7 +213,7 @@ test_group FileType [[ Name Args Address Complete Definition TestCommand 0 :echo 'Hello' - Last set from %s line 14]], + Last set from %s line 23]], script_location ), result @@ -175,7 +226,7 @@ test_group FileType string.format( [[ function Close_Window() abort - Last set from %s line 16 + Last set from %s line 25 1 wincmd - endfunction]], script_location @@ -190,7 +241,7 @@ test_group FileType string.format( [[ textwidth=80 - Last set from %s line 22]], + Last set from %s line 31]], script_location ), result @@ -230,7 +281,7 @@ describe('lua verbose:', function() eq( [[ nohlsearch - Last set from Lua]], + Last set from Lua (run Nvim with -V1 for more details)]], result ) end) diff --git a/test/functional/ex_cmds/wincmd_spec.lua b/test/functional/ex_cmds/wincmd_spec.lua index 98c6358f45..283f0991cb 100644 --- a/test/functional/ex_cmds/wincmd_spec.lua +++ b/test/functional/ex_cmds/wincmd_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local fn = helpers.fn -local command = helpers.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local eq = t.eq +local fn = n.fn +local command = n.command it(':wincmd accepts a count', function() clear() diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index f711731072..bb04bfa08a 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -1,14 +1,16 @@ -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + local eq, eval, clear, write_file, source, insert = - helpers.eq, helpers.eval, helpers.clear, helpers.write_file, helpers.source, helpers.insert -local pcall_err = helpers.pcall_err -local command = helpers.command -local feed_command = helpers.feed_command -local fn = helpers.fn -local api = helpers.api -local skip = helpers.skip -local is_os = helpers.is_os -local is_ci = helpers.is_ci + t.eq, n.eval, n.clear, t.write_file, n.source, n.insert +local pcall_err = t.pcall_err +local command = n.command +local feed_command = n.feed_command +local fn = n.fn +local api = n.api +local skip = t.skip +local is_os = t.is_os +local is_ci = t.is_ci local fname = 'Xtest-functional-ex_cmds-write' local fname_bak = fname .. '~' diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua index 78081fa45f..2299f33f06 100644 --- a/test/functional/ex_cmds/wundo_spec.lua +++ b/test/functional/ex_cmds/wundo_spec.lua @@ -1,13 +1,13 @@ -- Specs for :wundo and underlying functions -local helpers = require('test.functional.helpers')(after_each) -local command, clear, eval, spawn, nvim_prog, set_session = - helpers.command, - helpers.clear, - helpers.eval, - helpers.spawn, - helpers.nvim_prog, - helpers.set_session +local n = require('test.functional.testnvim')() + +local command = n.command +local clear = n.clear +local eval = n.eval +local spawn = n.spawn +local nvim_prog = n.nvim_prog +local set_session = n.set_session describe(':wundo', function() before_each(clear) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index 23ae1440e6..7c76d92228 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -1,8 +1,10 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command, eq, neq, write_file = helpers.command, helpers.eq, helpers.neq, helpers.write_file -local read_file = helpers.read_file -local is_os = helpers.is_os +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command, eq, neq, write_file = n.command, t.eq, t.neq, t.write_file +local read_file = t.read_file +local is_os = t.is_os describe(':wshada', function() local shada_file = 'wshada_test' |