diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/core/startup_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/editor/put_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/helpers.lua | 20 | ||||
-rw-r--r-- | test/functional/legacy/arglist_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/legacy/excmd_spec.lua | 619 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 42 | ||||
-rw-r--r-- | test/functional/plugin/lsp/diagnostic_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 14 | ||||
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/options_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 30 | ||||
-rw-r--r-- | test/functional/vimscript/executable_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/vimscript/let_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/vimscript/system_spec.lua | 23 |
14 files changed, 624 insertions, 172 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 51ab0e6382..4f9df4010e 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -24,6 +24,7 @@ local iswin = helpers.iswin local startswith = helpers.startswith local write_file = helpers.write_file local meths = helpers.meths +local alter_slashes = helpers.alter_slashes local testfile = 'Xtest_startuptime' after_each(function() @@ -33,9 +34,9 @@ end) describe('startup', function() it('--clean', function() clear() - ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil) + ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) ~= nil) clear('--clean') - ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil) + ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) == nil) end) it('--startuptime', function() diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua index cc9fce8f67..5050edff5c 100644 --- a/test/functional/editor/put_spec.lua +++ b/test/functional/editor/put_spec.lua @@ -879,9 +879,13 @@ describe('put command', function() ine of words 2]], curbuf_contents()) end) - local function bell_test(actions, should_ring) - local screen = Screen.new() + local screen + setup(function() + screen = Screen.new() screen:attach() + end) + + local function bell_test(actions, should_ring) if should_ring then -- check bell is not set by nvim before the action screen:sleep(50) @@ -899,7 +903,6 @@ describe('put command', function() end end end, unchanged=(not should_ring)} - screen:detach() end it('should not ring the bell with gp at end of line', function() diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 0c616e73fb..8c5a60657a 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -271,10 +271,22 @@ function module.command(cmd) end --- use for commands which expect nvim to quit -function module.expect_exit(...) - eq("EOF was received from Nvim. Likely the Nvim process crashed.", - module.pcall_err(...)) +-- Use for commands which expect nvim to quit. +-- The first argument can also be a timeout. +function module.expect_exit(fn_or_timeout, ...) + local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.' + if type(fn_or_timeout) == 'function' then + eq(eof_err_msg, module.pcall_err(fn_or_timeout, ...)) + else + eq(eof_err_msg, module.pcall_err(function(timeout, fn, ...) + fn(...) + while session:next_message(timeout) do + end + if session.eof_err then + error(session.eof_err[2]) + end + end, fn_or_timeout, ...)) + end end -- Evaluates a VimL expression. diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index 8379e426e0..f90da16d7b 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -4,6 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq +local expect_exit = helpers.expect_exit local feed = helpers.feed local pcall_err = helpers.pcall_err @@ -275,6 +276,6 @@ describe('argument list commands', function() 2 more files to edit. Quit anyway? | [Y]es, (N)o: ^ | ]]) - feed('Y') + expect_exit(100, feed, 'Y') end) end) diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index 6b3b265579..65957d85de 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -2,10 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command +local exec = helpers.exec local exec_lua = helpers.exec_lua +local expect_exit = helpers.expect_exit local feed = helpers.feed +local funcs = helpers.funcs +local iswin = helpers.iswin local meths = helpers.meths -local poke_eventloop = helpers.poke_eventloop local read_file = helpers.read_file local source = helpers.source local eq = helpers.eq @@ -37,152 +40,484 @@ describe('Ex command', function() end) end) -it(':confirm command dialog', function() +describe(':confirm command dialog', function() local screen local function start_new() clear() - screen = Screen.new(60, 20) + screen = Screen.new(75, 20) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- StatusLine, MsgSeparator + [2] = {reverse = true}, -- StatusLineNC + [3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + }) screen:attach() end - write_file('foo', 'foo1\n') - write_file('bar', 'bar1\n') - - -- Test for saving all the modified buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo2')") - command("new bar") - command("call setline(1, 'bar2')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar2 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo2 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('A') - poke_eventloop() - - eq('foo2\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - -- Test for discarding all the changes to modified buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo3')") - command("new bar") - command("call setline(1, 'bar3')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar3 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo3 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('D') - poke_eventloop() - - eq('foo2\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - -- Test for saving and discarding changes to some buffers - start_new() - command("set nomore") - command("new foo") - command("call setline(1, 'foo4')") - command("new bar") - command("call setline(1, 'bar4')") - command("wincmd b") - feed(':confirm qall\n') - screen:expect([[ - bar4 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo4 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - ~ | - ~ | - | - :confirm qall | - Save changes to "bar"? | - [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | - ]]) - feed('N') - screen:expect([[ - bar4 | - ~ | - ~ | - ~ | - ~ | - ~ | - bar [+] | - foo4 | - ~ | - ~ | - ~ | - ~ | - foo [+] | - | - | - :confirm qall | - Save changes to "bar"? | - | - Save changes to "foo"? | - [Y]es, (N)o, (C)ancel: ^ | - ]]) - feed('Y') - poke_eventloop() - - eq('foo4\n', read_file('foo')) - eq('bar2\n', read_file('bar')) - - os.remove('foo') - os.remove('bar') + -- Test for the :confirm command dialog + -- oldtest: Test_confirm_cmd() + it('works', function() + write_file('Xfoo', 'foo1\n') + write_file('Xbar', 'bar1\n') + + -- Test for saving all the modified buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo2') + new Xbar + call setline(1, 'bar2') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar2 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo2 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'A') + + eq('foo2\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + -- Test for discarding all the changes to modified buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo3') + new Xbar + call setline(1, 'bar3') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar3 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo3 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'D') + + eq('foo2\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + -- Test for saving and discarding changes to some buffers + start_new() + exec([[ + set nomore + new Xfoo + call setline(1, 'foo4') + new Xbar + call setline(1, 'bar4') + wincmd b + ]]) + feed(':confirm qall\n') + screen:expect([[ + bar4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {0:~ }| + {0:~ }| + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | + ]]) + feed('N') + screen:expect([[ + bar4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xbar [+] }| + foo4 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:Xfoo [+] }| + | + {1: }| + :confirm qall | + {3:Save changes to "Xbar"?} | + | + {3:Save changes to "Xfoo"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + expect_exit(100, feed, 'Y') + + eq('foo4\n', read_file('Xfoo')) + eq('bar2\n', read_file('Xbar')) + + os.remove('Xfoo') + os.remove('Xbar') + end) + + -- oldtest: Test_confirm_cmd_cancel() + it('can be cancelled', function() + -- Test for closing a window with a modified buffer + start_new() + screen:try_resize(75, 10) + exec([[ + set nohidden nomore + new + call setline(1, 'abc') + ]]) + feed(':confirm close\n') + screen:expect([[ + abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {1: }| + :confirm close | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {0:~ }| + {0:~ }| + {2:[No Name] }| + | + ]]) + feed(':confirm close\n') + screen:expect([[ + abc | + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] [+] }| + | + {1: }| + :confirm close | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('N') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + + -- oldtest: Test_confirm_q_wq() + it('works with :q and :wq', function() + write_file('Xfoo', 'foo') + start_new() + screen:try_resize(75, 8) + exec([[ + set hidden nomore + call setline(1, 'abc') + edit Xfoo + set nofixendofline + ]]) + feed(':confirm q\n') + screen:expect([[ + foo | + {0:~ }| + {0:~ }| + {0:~ }| + {1: }| + :confirm q | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + command('edit Xfoo') + feed(':confirm wq\n') + screen:expect([[ + foo | + {0:~ }| + {0:~ }| + {0:~ }| + {1: }| + "Xfoo" [noeol] 1L, 3B written | + {3:Save changes to "Untitled"?} | + {3:[Y]es, (N)o, (C)ancel: }^ | + ]]) + feed('C') + screen:expect([[ + ^abc | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + "Xfoo" [noeol] 1L, 3B written | + ]]) + + os.remove('Xfoo') + end) + + -- oldtest: Test_confirm_write_ro() + it('works when writing a read-only file', function() + write_file('Xconfirm_write_ro', 'foo\n') + start_new() + screen:try_resize(75, 8) + exec([[ + set ruler + set nobackup ff=unix cmdheight=2 + edit Xconfirm_write_ro + norm Abar + ]]) + + -- Try to write with 'ro' option. + feed(':set ro | confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {0:~ }| + {1: }| + :set ro | confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('N') + screen:expect([[ + fooba^r | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + 1,6 All | + ]]) + eq('foo\n', read_file('Xconfirm_write_ro')) + + feed(':confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + "Xconfirm_write_ro" [unix] 1L, 7B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :confirm w | + {3:'readonly' option is set for "Xconfirm_write_ro".} | + {3:Do you wish to write anyway?} | + "Xconfirm_write_ro" 1L, 7B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('foobar\n', read_file('Xconfirm_write_ro')) + feed('<CR>') -- suppress hit-enter prompt + + -- Try to write with read-only file permissions. + funcs.setfperm('Xconfirm_write_ro', 'r--r--r--') + feed(':set noro | silent undo | confirm w\n') + screen:expect([[ + foobar | + {0:~ }| + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + foobar | + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + "Xconfirm_write_ro" [unix] 1L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + foobar | + {1: }| + :set noro | silent undo | confirm w | + {3:File permissions of "Xconfirm_write_ro" are read-only.} | + {3:It may still be possible to write it.} | + {3:Do you wish to try?} | + "Xconfirm_write_ro" 1L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('foo\n', read_file('Xconfirm_write_ro')) + feed('<CR>') -- suppress hit-enter prompt + + os.remove('Xconfirm_write_ro') + end) + + -- oldtest: Test_confirm_write_partial_file() + it('works when writing a partial file', function() + write_file('Xwrite_partial', 'a\nb\nc\nd\n') + start_new() + screen:try_resize(75, 8) + exec([[ + set ruler + set nobackup ff=unix cmdheight=2 + edit Xwrite_partial + ]]) + + feed(':confirm 2,3w\n') + screen:expect([[ + a | + b | + c | + d | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('N') + screen:expect([[ + ^a | + b | + c | + d | + {0:~ }| + {0:~ }| + | + 1,1 All | + ]]) + eq('a\nb\nc\nd\n', read_file('Xwrite_partial')) + os.remove('Xwrite_partial') + + feed(':confirm 2,3w\n') + screen:expect([[ + a | + b | + c | + d | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + {3:(Y)es, [N]o: }^ | + ]]) + feed('Y') + if iswin() then + screen:expect([[ + a | + b | + c | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + "Xwrite_partial" [New][unix] 2L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + else + screen:expect([[ + a | + b | + c | + {1: }| + :confirm 2,3w | + {3:Write partial file?} | + "Xwrite_partial" [New] 2L, 4B written | + {3:Press ENTER or type command to continue}^ | + ]]) + end + eq('b\nc\n', read_file('Xwrite_partial')) + + os.remove('Xwrite_partial') + end) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 883e0e373b..57bb2f9765 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2148,6 +2148,13 @@ describe('lua stdlib', function() ]] eq('2', funcs.luaeval "BUF") eq(2, funcs.luaeval "#vim.api.nvim_list_bufs()") + + -- vim.cmd can be indexed with a command name + exec_lua [[ + vim.cmd.let 'g:var = 2' + ]] + + eq(2, funcs.luaeval "vim.g.var") end) it('vim.regex', function() @@ -2493,6 +2500,41 @@ describe('lua stdlib', function() eq(false, pcall_result) end) + + describe('returns -2 when interrupted', function() + before_each(function() + local channel = meths.get_api_info()[1] + meths.set_var('channel', channel) + end) + + it('without callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()<CR>') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('<C-C>') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + + it('with callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000, function() end) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()<CR>') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('<C-C>') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + end) end) it('vim.notify_once', function() diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua index 19b01edb29..f73ffc29b0 100644 --- a/test/functional/plugin/lsp/diagnostic_spec.lua +++ b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -221,7 +221,7 @@ describe('vim.lsp.diagnostic', function() local diags = vim.diagnostic.get(diagnostic_bufnr) vim.lsp.stop_client(client_id) - vim.lsp._vim_exit_handler() + vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) return diags ]], line) eq(1, #result) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 6db969693e..c166982052 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -137,7 +137,7 @@ local function test_rpc_server(config) end stop() if config.test_name then - exec_lua("lsp._vim_exit_handler()") + exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") end end @@ -172,7 +172,7 @@ describe('LSP', function() end) after_each(function() - exec_lua("lsp._vim_exit_handler()") + exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") -- exec_lua("lsp.stop_all_clients(true)") end) @@ -249,7 +249,7 @@ describe('LSP', function() after_each(function() stop() exec_lua("lsp.stop_client(lsp.get_active_clients(), true)") - exec_lua("lsp._vim_exit_handler()") + exec_lua("vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false })") end) it('should run correctly', function() @@ -505,7 +505,7 @@ describe('LSP', function() } end) - it('_text_document_did_save_handler sends didSave with bool textDocumentSync.save', function() + it('BufWritePost sends didSave with bool textDocumentSync.save', function() local expected_handlers = { {NIL, {}, {method="shutdown", client_id=1}}; {NIL, {}, {method="start", client_id=1}}; @@ -526,7 +526,7 @@ describe('LSP', function() exec_lua([=[ BUFFER = vim.api.nvim_get_current_buf() lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID) - lsp._text_document_did_save_handler(BUFFER) + vim.api.nvim_exec_autocmds('BufWritePost', { buffer = BUFFER, modeline = false }) ]=]) else client.stop() @@ -535,7 +535,7 @@ describe('LSP', function() } end) - it('_text_document_did_save_handler sends didSave including text if server capability is set', function() + it('BufWritePost sends didSave including text if server capability is set', function() local expected_handlers = { {NIL, {}, {method="shutdown", client_id=1}}; {NIL, {}, {method="start", client_id=1}}; @@ -557,7 +557,7 @@ describe('LSP', function() BUFFER = vim.api.nvim_get_current_buf() vim.api.nvim_buf_set_lines(BUFFER, 0, -1, true, {"help me"}) lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID) - lsp._text_document_did_save_handler(BUFFER) + vim.api.nvim_exec_autocmds('BufWritePost', { buffer = BUFFER, modeline = false }) ]=]) else client.stop() diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index a1423c98a8..03cd4bfd06 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -215,7 +215,7 @@ describe('ui/cursor', function() m.hl_id = 60 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 65 end + if m.id_lm then m.id_lm = 61 end end -- Assert the new expectation. diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index c2b0bcdb64..8d7c404637 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -51,7 +51,7 @@ describe('UI receives option updates', function() end) it('on attach #11372', function() - clear() + clear{args_rm={'--headless'}} local evs = {} screen = Screen.new(20,5) -- Override mouse_on/mouse_off handlers. @@ -88,6 +88,13 @@ describe('UI receives option updates', function() eq(expected, screen.options) end) + command("set pumblend=50") + expected.pumblend = 50 + screen:expect(function() + eq(expected, screen.options) + end) + + -- check handling of out-of-bounds value command("set pumblend=-1") expected.pumblend = 0 screen:expect(function() diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 1e1066d48a..2ffd3149a6 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -98,13 +98,41 @@ describe('statusline clicks', function() eq('0 2 r', eval("g:testvar")) end) - it("click works with modifiers #18994", function() + it("works with modifiers #18994", function() meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') meths.input_mouse('right', 'press', 's', 0, 6, 17) eq('0 1 r s', eval("g:testvar")) meths.input_mouse('left', 'press', 's', 0, 6, 17) eq('0 1 l s', eval("g:testvar")) end) + + it("works for global statusline with vertical splits #19186", function() + command('set laststatus=3') + meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T') + command('vsplit') + screen:expect([[ + ^ │ | + ~ │~ | + ~ │~ | + ~ │~ | + ~ │~ | + ~ │~ | + Clicky stuff Clicky stuff| + | + ]]) + + -- clickable area on the right + meths.input_mouse('left', 'press', '', 0, 6, 35) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 35) + eq('0 1 r', eval("g:testvar")) + + -- clickable area on the left + meths.input_mouse('left', 'press', '', 0, 6, 5) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 5) + eq('0 1 r', eval("g:testvar")) + end) end) describe('global statusline', function() diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua index 048a65188d..b4162b2336 100644 --- a/test/functional/vimscript/executable_spec.lua +++ b/test/functional/vimscript/executable_spec.lua @@ -17,6 +17,21 @@ describe('executable()', function() eq(1, call('executable', 'false')) end) + if iswin() then + it('exepath respects shellslash', function() + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + eq([[test\functional\fixtures\bin\null.CMD]], call('fnamemodify', call('exepath', 'null'), ':.')) + command('set shellslash') + eq('test/functional/fixtures/bin/null.CMD', call('fnamemodify', call('exepath', 'null'), ':.')) + end) + + it('stdpath respects shellslash', function() + eq([[build\Xtest_xdg\share\nvim-data]], call('fnamemodify', call('stdpath', 'data'), ':.')) + command('set shellslash') + eq('build/Xtest_xdg/share/nvim-data', call('fnamemodify', call('stdpath', 'data'), ':.')) + end) + end + it('fails for invalid values', function() for _, input in ipairs({'v:null', 'v:true', 'v:false', '{}', '[]'}) do eq('Vim(call):E928: String required', exc_exec('call executable('..input..')')) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index ca1b5e8907..86905199a8 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -7,6 +7,7 @@ local eval = helpers.eval local meths = helpers.meths local exec = helpers.exec local exec_capture = helpers.exec_capture +local expect_exit = helpers.expect_exit local source = helpers.source local testprg = helpers.testprg @@ -28,7 +29,7 @@ describe(':let', function() it(":unlet self-referencing node in a List graph #6070", function() -- :unlet-ing a self-referencing List must not allow GC on indirectly -- referenced in-scope Lists. Before #6070 this caused use-after-free. - source([=[ + expect_exit(100, source, [=[ let [l1, l2] = [[], []] echo 'l1:' . id(l1) echo 'l2:' . id(l2) diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index c915556c57..a778e2f435 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -630,7 +630,7 @@ end) describe('shell :!', function() before_each(clear) - it(':{range}! with powershell filter/redirect #16271', function() + it(':{range}! with powershell filter/redirect #16271 #19250', function() local screen = Screen.new(500, 8) screen:attach() local found = helpers.set_shell_powershell(true) @@ -639,18 +639,25 @@ describe('shell :!', function() 1 4 2]]) - feed(':4verbose %!sort<cr>') - screen:expect{ - any=[[Executing command: .?Start%-Process sort %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait]] - } + if iswin() then + feed(':4verbose %!sort /R<cr>') + screen:expect{ + any=[[Executing command: .?Start%-Process sort %-ArgumentList "/R" %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait]] + } + else + feed(':4verbose %!sort -r<cr>') + screen:expect{ + any=[[Executing command: .?Start%-Process sort %-ArgumentList "%-r" %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait]] + } + end feed('<CR>') if found then -- Not using fake powershell, so we can test the result. expect([[ - 1 - 2 + 4 3 - 4]]) + 2 + 1]]) end end) end) |