From a94632d2126823bcd593f4cdd5a41aaff197b291 Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Fri, 7 Jan 2022 12:28:17 -0500 Subject: vim-patch:8.2.3917: the eval.txt help file is way too big Problem: The eval.txt help file is way too big. Solution: Move the builtin function details to a separate file. https://github.com/vim/vim/commit/1cae5a0a034d0545360387407a7a409310f1efe2 Note: Neovim-specific references to |functions| were changed to |builtin-functions|. This included updates to: 1. test/functional/vimscript/functions_spec.lua 2. test/functional/vimscript/eval_spec.lua 3. runtime/doc/lua.txt --- test/functional/vimscript/eval_spec.lua | 2 +- test/functional/vimscript/functions_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index e1459ab5b8..0c2ca8de78 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -5,7 +5,7 @@ -- null_spec.lua -- operators_spec.lua -- --- Tests for the Vimscript |functions| library should live in: +-- Tests for the Vimscript |builtin-functions| library should live in: -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua index 0ad7fd8010..20c1400030 100644 --- a/test/functional/vimscript/functions_spec.lua +++ b/test/functional/vimscript/functions_spec.lua @@ -1,4 +1,4 @@ --- Tests for misc Vimscript |functions|. +-- Tests for misc Vimscript |builtin-functions|. -- -- If a function is non-trivial, consider moving its spec to: -- test/functional/vimscript/_spec.lua -- cgit From 74998b0449c4df0494c3bfe5d4034c575d972406 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 3 Feb 2022 13:43:48 +0800 Subject: fix(event-loop): call vpeekc() directly first to check for character Expand mappings first by calling `vpeekc()` directly. --- test/functional/vimscript/timer_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index e45b64422f..25e46062b7 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -272,4 +272,12 @@ describe('timers', function() ]] eq("Vim(call):E48: Not allowed in sandbox", exc_exec("sandbox call timer_start(0, 'Scary')")) end) + + it('can be triggered after an empty string mapping', function() + local screen = Screen.new(40, 6) + screen:attach() + command([=[imap [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=]) + feed('i') + screen:expect({any='E605: Exception not caught: x'}) + end) end) -- cgit From 72652cbc46f568128bfc296ba63fb2d26941da8e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 27 Mar 2022 10:25:55 -0700 Subject: feat(test): use nvim_exec in helpers.source() #16064 helpers.source() was a hack to work around the lack of anonymous :source. Its "create tempfile" behavior is not a required part of most tests that use it. Some tests still need the old "create tempfile" behavior either because they test SID behavior, or because of missing nvim_exec features: #16071 --- test/functional/vimscript/lang_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/lang_spec.lua b/test/functional/vimscript/lang_spec.lua index d5254986ab..90437f2ee1 100644 --- a/test/functional/vimscript/lang_spec.lua +++ b/test/functional/vimscript/lang_spec.lua @@ -11,6 +11,7 @@ describe('vimscript', function() return end source([[ + let s:foo = 1 func! _dummy_function() echo 1 endfunc -- cgit From a9665bb12cd8cbacbc6ef6df66c1989b0c6f9fcc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 30 Mar 2022 05:25:00 +0800 Subject: fix(event-loop): duplicate display updating logic in vgetorpeek() (#17913) --- test/functional/vimscript/timer_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 25e46062b7..20f2afb20f 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -273,7 +273,7 @@ describe('timers', function() eq("Vim(call):E48: Not allowed in sandbox", exc_exec("sandbox call timer_start(0, 'Scary')")) end) - it('can be triggered after an empty string mapping', function() + it('can be triggered after an empty string mapping #17257', function() local screen = Screen.new(40, 6) screen:attach() command([=[imap [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=]) -- cgit From e63e5d1dbd3dd4711efa0ecf9e844ff308b370a6 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 15 Apr 2022 12:35:06 +0200 Subject: docs: typo fixes (#17859) Co-authored-by: Elias Alves Moura Co-authored-by: venkatesh Co-authored-by: zeertzjq Co-authored-by: Vikas Raj <24727447+numToStr@users.noreply.github.com> Co-authored-by: Steve Vermeulen Co-authored-by: Evgeni Chasnovski Co-authored-by: rwxd Co-authored-by: casswedson <58050969+casswedson@users.noreply.github.com> --- test/functional/vimscript/system_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 24a1f05390..bedf7e5498 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -527,7 +527,7 @@ describe('systemlist()', function() end) -- Unlike `system()` which uses SOH to represent NULs, with `systemlist()` - -- input and ouput are the same. + -- input and output are the same. describe('with linefeed characters inside list items', function() it('converts linefeed characters to NULs', function() eq({'l1\np2', 'line2\na\nb', 'l3'}, -- cgit From 10693a9e8a5697f0f4cb6797fc6fbe073a6f182b Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 23 Apr 2022 12:04:38 +0200 Subject: fix(ci): workaround bug in msgpackparse() on windows caused by api level bump --- test/functional/vimscript/msgpack_functions_spec.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua index 837b629858..cab67d77e4 100644 --- a/test/functional/vimscript/msgpack_functions_spec.lua +++ b/test/functional/vimscript/msgpack_functions_spec.lua @@ -5,6 +5,7 @@ local eval, eq = helpers.eval, helpers.eq local command = helpers.command local nvim = helpers.nvim local exc_exec = helpers.exc_exec +local iswin = helpers.iswin describe('msgpack*() functions', function() before_each(clear) @@ -466,6 +467,11 @@ describe('msgpackparse() function', function() eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again + if iswin() then + helpers.assert_alive() + pending('msgpackparse() has a bug on windows') + return + end eq({'error_types', 'functions', 'types', 'ui_events', 'ui_options', 'version'}, api_info) end) -- cgit From 519e4c44720be9b0c8584cb53a902bc1e5bfe3a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 26 Apr 2022 11:35:05 +0800 Subject: test: correct order of arguments to eq() and neq() --- test/functional/vimscript/reltime_spec.lua | 4 ++-- test/functional/vimscript/setpos_spec.lua | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua index d87943e485..6d661402a6 100644 --- a/test/functional/vimscript/reltime_spec.lua +++ b/test/functional/vimscript/reltime_spec.lua @@ -12,7 +12,7 @@ describe('reltimestr(), reltimefloat()', function() local later = reltime() local elapsed = reltime(now) - neq(reltimestr(elapsed), '0.0') + neq('0.0', reltimestr(elapsed)) ok(reltimefloat(elapsed) > 0.0) -- original vim test for < 0.1, but easily fails on travis ok(nil ~= string.match(reltimestr(elapsed), "0%.")) @@ -26,7 +26,7 @@ describe('reltimestr(), reltimefloat()', function() eq(0.0, reltimefloat(same)) local differs = reltime(now, later) - neq(reltimestr(differs), '0.0') + neq('0.0', reltimestr(differs)) ok(reltimefloat(differs) > 0.0) -- original vim test for < 0.1, but easily fails on travis ok(nil ~= string.match(reltimestr(differs), "0%.")) diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua index 935f387bcc..02e550dcc0 100644 --- a/test/functional/vimscript/setpos_spec.lua +++ b/test/functional/vimscript/setpos_spec.lua @@ -24,41 +24,41 @@ describe('setpos() function', function() end) it('can set the current cursor position', function() setpos(".", {0, 2, 1, 0}) - eq(getpos("."), {0, 2, 1, 0}) + eq({0, 2, 1, 0}, getpos(".")) setpos(".", {2, 1, 1, 0}) - eq(getpos("."), {0, 1, 1, 0}) + eq({0, 1, 1, 0}, getpos(".")) local ret = exc_exec('call setpos(".", [1, 1, 1, 0])') eq(0, ret) end) it('can set lowercase marks in the current buffer', function() setpos("'d", {0, 2, 1, 0}) - eq(getpos("'d"), {0, 2, 1, 0}) + eq({0, 2, 1, 0}, getpos("'d")) command('undo') command('call setpos("\'d", [2, 3, 1, 0])') - eq(getpos("'d"), {0, 3, 1, 0}) + eq({0, 3, 1, 0}, getpos("'d")) end) it('can set lowercase marks in other buffers', function() local retval = setpos("'d", {1, 2, 1, 0}) eq(0, retval) setpos("'d", {1, 2, 1, 0}) - eq(getpos("'d"), {0, 0, 0, 0}) + eq({0, 0, 0, 0}, getpos("'d")) command('wincmd w') - eq(eval('bufnr("%")'), 1) - eq(getpos("'d"), {0, 2, 1, 0}) + eq(1, eval('bufnr("%")')) + eq({0, 2, 1, 0}, getpos("'d")) end) it("fails when setting a mark in a buffer that doesn't exist", function() local retval = setpos("'d", {3, 2, 1, 0}) eq(-1, retval) - eq(getpos("'d"), {0, 0, 0, 0}) + eq({0, 0, 0, 0}, getpos("'d")) retval = setpos("'D", {3, 2, 1, 0}) eq(-1, retval) - eq(getpos("'D"), {0, 0, 0, 0}) + eq({0, 0, 0, 0}, getpos("'D")) end) it('can set uppercase marks', function() setpos("'D", {2, 2, 3, 0}) - eq(getpos("'D"), {2, 2, 3, 0}) + eq({2, 2, 3, 0}, getpos("'D")) -- Can set a mark in another buffer setpos("'D", {1, 2, 2, 0}) - eq(getpos("'D"), {1, 2, 2, 0}) + eq({1, 2, 2, 0}, getpos("'D")) end) end) -- cgit From 3933592338934933adfeb35dca8472bd28838ec8 Mon Sep 17 00:00:00 2001 From: Andrey Mishchenko Date: Tue, 26 Apr 2022 23:58:25 -0400 Subject: fix: has() should preserve v:shell_error #18280 fixes #18278 --- test/functional/vimscript/has_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua index c03fd13e0c..4d9b226434 100644 --- a/test/functional/vimscript/has_spec.lua +++ b/test/functional/vimscript/has_spec.lua @@ -68,4 +68,11 @@ describe('has()', function() eq(0, funcs.has('wsl')) end end) + + it('does not change v:shell_error', function() + local nvim_prog = helpers.nvim_prog + funcs.system({nvim_prog, '-es', '+73cquit'}) + funcs.has('python3') -- use a call whose implementation shells out + eq(73, funcs.eval('v:shell_error')) + end) end) -- cgit From 2ba539f449a95f38463a61b189e203a5fe306fc0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Apr 2022 13:11:35 +0800 Subject: fix(input): only disable mapped CTRL-C interrupts when getting input (#18310) --- test/functional/vimscript/system_spec.lua | 45 ++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index bedf7e5498..9cc6424d31 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -268,7 +268,7 @@ describe('system()', function() :call system("for /L %I in (1,0,2) do @echo y") |]] or [[ :call system("yes") |]])) - feed('') + feed('foo') screen:expect([[ ^ | ~ | @@ -286,6 +286,49 @@ describe('system()', function() Type :qa and press to exit Nvim | ]]) end) + + it('`yes` interrupted with mapped CTRL-C', function() + command('nnoremap i') + feed(':call system("' .. (iswin() + and 'for /L %I in (1,0,2) do @echo y' + or 'yes') .. '")') + screen:expect([[ + | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | +]] .. (iswin() + and [[ + :call system("for /L %I in (1,0,2) do @echo y") |]] + or [[ + :call system("yes") |]])) + feed('foo') + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + -- INSERT -- | + ]]) + end) end) describe('passing no input', function() -- cgit From 4fb48c5654d9ffbffbdcdd80d0498b1ea3c8e68b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 3 May 2022 15:08:35 +0200 Subject: feat(server): set $NVIM, unset $NVIM_LISTEN_ADDRESS #11009 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROBLEM ------------------------------------------------------------------------ $NVIM_LISTEN_ADDRESS has conflicting purposes as both a parameter ("the current process should listen on this address") and a descriptor ("the current process is a child of this address"). This contradiction means the presence of NVIM_LISTEN_ADDRESS is ambiguous, so child Nvim always tries to listen on its _parent's_ socket. This is the cause of lots of "Failed to start server" spam in our test/CI logs: WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-4480-0 WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-2168-0 SOLUTION ------------------------------------------------------------------------ 1. Set $NVIM to the parent v:servername, *only* in child processes. - Now the correct way to detect a "parent" Nvim is to check for $NVIM. 2. Do NOT set $NVIM_LISTEN_ADDRESS in child processes. 3. On startup if $NVIM_LISTEN_ADDRESS exists, unset it immediately after server init. 4. Open a channel to parent automatically, expose it as v:parent. Fixes #3118 Fixes #6764 Fixes #9336 Ref https://github.com/neovim/neovim/pull/8247#issuecomment-380275696 Ref #8696 --- test/functional/vimscript/server_spec.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index 238d1aeb0f..de64a77b4d 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval -local command = helpers.command local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths local iswin = helpers.iswin local ok = helpers.ok @@ -16,27 +15,25 @@ end describe('server', function() before_each(clear) - it('serverstart() sets $NVIM_LISTEN_ADDRESS on first invocation', function() - -- Unset $NVIM_LISTEN_ADDRESS - command('let $NVIM_LISTEN_ADDRESS = ""') - + it('serverstart(), serverstop() does not set $NVIM', function() local s = eval('serverstart()') assert(s ~= nil and s:len() > 0, "serverstart() returned empty") - eq(s, eval('$NVIM_LISTEN_ADDRESS')) + eq('', eval('$NVIM')) + eq('', eval('$NVIM_LISTEN_ADDRESS')) eq(1, eval("serverstop('"..s.."')")) eq('', eval('$NVIM_LISTEN_ADDRESS')) end) it('sets new v:servername if $NVIM_LISTEN_ADDRESS is invalid', function() clear({env={NVIM_LISTEN_ADDRESS='.'}}) - eq('.', eval('$NVIM_LISTEN_ADDRESS')) + -- Cleared on startup. + eq('', eval('$NVIM_LISTEN_ADDRESS')) local servers = funcs.serverlist() eq(1, #servers) ok(string.len(servers[1]) > 4) -- Like /tmp/nvim…/… or \\.\pipe\… end) - it('sets v:servername at startup or if all servers were stopped', - function() + it('sets v:servername at startup or if all servers were stopped', function() local initial_server = meths.get_vvar('servername') assert(initial_server ~= nil and initial_server:len() > 0, 'v:servername was not initialized') @@ -55,11 +52,13 @@ describe('server', function() eq(1, funcs.serverstop(funcs.serverlist()[1])) eq('', meths.get_vvar('servername')) - -- v:servername will take the next available server. + -- v:servername and $NVIM take the next available server. local servername = (iswin() and [[\\.\pipe\Xtest-functional-server-pipe]] or 'Xtest-functional-server-socket') funcs.serverstart(servername) eq(servername, meths.get_vvar('servername')) + -- Not set in the current process, only in children. + eq('', eval('$NVIM')) end) it('serverstop() returns false for invalid input', function() @@ -136,7 +135,6 @@ end) describe('startup --listen', function() it('validates', function() clear() - local cmd = { unpack(helpers.nvim_argv) } table.insert(cmd, '--listen') matches('nvim.*: Argument missing after: "%-%-listen"', funcs.system(cmd)) -- cgit From 3c1bc75447841a2cc4d0222657556aa172c91915 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 21 May 2022 23:07:34 +0200 Subject: fix(tests): fix some screen.lua warnings --- test/functional/vimscript/execute_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index e21c71dc7f..a733b098f5 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -153,7 +153,7 @@ describe('execute()', function() function! Test3() echo 1234 let x = execute('echoerr "abcdef"', 'silent!') - echon 'ABCD' + echon 'ABCDXZYZ' endfunction " test 4: silenced echoerr goes as usual @@ -214,7 +214,7 @@ describe('execute()', function() ~ | ~ | ~ | - 1234ABCD | + 1234ABCDXZYZ | ]]) feed([[:call Test4()]]) -- cgit From 8f065205946844d87f00d6c55517521e3809f821 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 May 2022 21:44:15 -0700 Subject: feat(logging): include test-id in log messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: 1. Log messages (especially in CI) are hard to correlate with tests. 2. Since b353a5c05f02 #11886, dumplog() prints the logs next to test failures. This is noisy and gets in the way of the test results. Solution: 1. Associate an incrementing id with each test and include it in log messages. - FUTURE: add v:name so Nvim instances can be formally "named"? 2. Mention "child" in log messages if the current Nvim is a child (based on the presence of $NVIM). BEFORE: DBG … 12345 UI: event DBG … 12345 log_server_msg:722: RPC ->ch 1: … DBG … 12345 UI: flush DBG … 12345 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … 23454 UI: stop INF … 23454 os_exit:594: Nvim exit: 0 AFTER: DBG … T57 UI: event DBG … T57 log_server_msg:722: RPC ->ch 1: … DBG … T57 UI: flush DBG … T57 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … T57/child UI: stop INF … T57/child os_exit:594: Nvim exit: 0 --- test/functional/vimscript/let_spec.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 4ff4090a18..6e93655e32 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -47,33 +47,33 @@ describe(':let', function() end) it("multibyte env var #8398 #9267", function() - command("let $NVIM_TEST = 'AìaB'") - eq('AìaB', eval('$NVIM_TEST')) - command("let $NVIM_TEST = 'AaあB'") - eq('AaあB', eval('$NVIM_TEST')) + command("let $NVIM_TEST_LET = 'AìaB'") + eq('AìaB', eval('$NVIM_TEST_LET')) + command("let $NVIM_TEST_LET = 'AaあB'") + eq('AaあB', eval('$NVIM_TEST_LET')) local mbyte = [[\p* .ม .ม .ม .ม่ .ม่ .ม่ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹֻ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ ֹֻ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ a a a ca ca ca à à à]] - command("let $NVIM_TEST = '"..mbyte.."'") - eq(mbyte, eval('$NVIM_TEST')) + command("let $NVIM_TEST_LET = '"..mbyte.."'") + eq(mbyte, eval('$NVIM_TEST_LET')) end) it("multibyte env var to child process #8398 #9267", function() - local cmd_get_child_env = "let g:env_from_child = system(['"..nvim_dir.."/printenv-test', 'NVIM_TEST'])" - command("let $NVIM_TEST = 'AìaB'") + local cmd_get_child_env = "let g:env_from_child = system(['"..nvim_dir.."/printenv-test', 'NVIM_TEST_LET'])" + command("let $NVIM_TEST_LET = 'AìaB'") command(cmd_get_child_env) - eq(eval('$NVIM_TEST'), eval('g:env_from_child')) + eq(eval('$NVIM_TEST_LET'), eval('g:env_from_child')) - command("let $NVIM_TEST = 'AaあB'") + command("let $NVIM_TEST_LET = 'AaあB'") command(cmd_get_child_env) - eq(eval('$NVIM_TEST'), eval('g:env_from_child')) + eq(eval('$NVIM_TEST_LET'), eval('g:env_from_child')) local mbyte = [[\p* .ม .ม .ม .ม่ .ม่ .ม่ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹֻ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ ֹֻ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹ ֹ ֹ .ֹ .ֹ .ֹ ֹֻ ֹֻ .ֹֻ .ֹֻ .ֹֻ a a a ca ca ca à à à]] - command("let $NVIM_TEST = '"..mbyte.."'") + command("let $NVIM_TEST_LET = '"..mbyte.."'") command(cmd_get_child_env) - eq(eval('$NVIM_TEST'), eval('g:env_from_child')) + eq(eval('$NVIM_TEST_LET'), eval('g:env_from_child')) end) it("release of list assigned to l: variable does not trigger assertion #12387, #12430", function() -- cgit From 1f2c2a35ad14cfac002d87073471bd84a52860bf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 1 Jun 2022 11:28:14 -0700 Subject: feat(server): instance "name", store pipes in stdpath(state) Problem: - Unix sockets are created in random /tmp dirs. - /tmp is messy, unclear when OSes actually clear it. - The generated paths are very ugly. This adds friction to reasoning about which paths belong to which Nvim instances. - No way to provide a human-friendly way to identify Nvim instances in logs or server addresses. Solution: - Store unix sockets in stdpath('state') - Allow --listen "name" and serverstart("name") to given a name (which is appended to a generated path). TODO: - is stdpath(state) the right place? --- test/functional/vimscript/server_spec.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index de64a77b4d..ea07be231d 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -30,7 +30,7 @@ describe('server', function() eq('', eval('$NVIM_LISTEN_ADDRESS')) local servers = funcs.serverlist() eq(1, #servers) - ok(string.len(servers[1]) > 4) -- Like /tmp/nvim…/… or \\.\pipe\… + ok(string.len(servers[1]) > 4) -- "~/.local/state/nvim…/…" or "\\.\pipe\…" end) it('sets v:servername at startup or if all servers were stopped', function() @@ -54,7 +54,7 @@ describe('server', function() -- v:servername and $NVIM take the next available server. local servername = (iswin() and [[\\.\pipe\Xtest-functional-server-pipe]] - or 'Xtest-functional-server-socket') + or './Xtest-functional-server-socket') funcs.serverstart(servername) eq(servername, meths.get_vvar('servername')) -- Not set in the current process, only in children. @@ -66,7 +66,7 @@ describe('server', function() eq(0, eval("serverstop('bogus-socket-name')")) end) - it('parses endpoints correctly', function() + it('parses endpoints', function() clear_serverlist() eq({}, funcs.serverlist()) @@ -101,6 +101,10 @@ describe('server', function() eq(expected, funcs.serverlist()) clear_serverlist() + -- Address without slashes is a "name" which is appended to a generated path. #8519 + matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], funcs.serverstart('xtest1.2.3.4')) + clear_serverlist() + eq('Vim:Failed to start server: invalid argument', pcall_err(funcs.serverstart, '127.0.0.1:65536')) -- invalid port eq({}, funcs.serverlist()) @@ -113,7 +117,7 @@ describe('server', function() -- Add some servers. local servs = (iswin() and { [[\\.\pipe\Xtest-pipe0934]], [[\\.\pipe\Xtest-pipe4324]] } - or { [[Xtest-pipe0934]], [[Xtest-pipe4324]] }) + or { [[./Xtest-pipe0934]], [[./Xtest-pipe4324]] }) for _, s in ipairs(servs) do eq(s, eval("serverstart('"..s.."')")) end @@ -146,9 +150,13 @@ describe('startup --listen', function() it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function() local addr = (iswin() and [[\\.\pipe\Xtest-listen-pipe]] - or 'Xtest-listen-pipe') - clear({ env={ NVIM_LISTEN_ADDRESS='Xtest-env-pipe' }, + or './Xtest-listen-pipe') + clear({ env={ NVIM_LISTEN_ADDRESS='./Xtest-env-pipe' }, args={ '--listen', addr } }) eq(addr, meths.get_vvar('servername')) + + -- Address without slashes is a "name" which is appended to a generated path. #8519 + clear({ args={ '--listen', 'test-name' } }) + matches([[.*[/\\]test%-name[^/\\]*]], meths.get_vvar('servername')) end) end) -- cgit From 9f28eddfab368697c21e6628fdf55af5ec4f4c39 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sun, 19 Jun 2022 16:08:43 +0300 Subject: fix(float): make `screen*()` functions respect floating windows Resolves #19013. --- test/functional/vimscript/screenchar_spec.lua | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/functional/vimscript/screenchar_spec.lua (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua new file mode 100644 index 0000000000..767e3c57ef --- /dev/null +++ b/test/functional/vimscript/screenchar_spec.lua @@ -0,0 +1,69 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq +local command, meths, funcs = helpers.command, helpers.meths, helpers.funcs +local tbl_deep_extend = helpers.tbl_deep_extend + +-- Set up two overlapping floating windows +local setup_floating_windows = function() + local base_opts = { + relative = 'editor', + height = 1, + width = 2, + anchor = 'NW', + style = 'minimal', + border = 'none', + } + + local bufnr_1 = meths.create_buf(false, true) + meths.buf_set_lines(bufnr_1, 0, -1, true, { 'aa' }) + local opts_1 = tbl_deep_extend('force', { row = 0, col = 0, zindex = 11 }, base_opts) + meths.open_win(bufnr_1, false, opts_1) + + local bufnr_2 = meths.create_buf(false, true) + meths.buf_set_lines(bufnr_2, 0, -1, true, { 'bb' }) + local opts_2 = tbl_deep_extend('force', { row = 0, col = 1, zindex = 10 }, base_opts) + meths.open_win(bufnr_2, false, opts_2) + + command('redraw') +end + +describe('screenchar() and family respect floating windows', function() + before_each(function() + clear() + -- These commands result into visible text `aabc`. + -- `aab` - from floating windows, `c` - from text in regular window. + meths.buf_set_lines(0, 0, -1, true, { 'cccc' }) + setup_floating_windows() + end) + + it('screenattr()', function() + local attr_1 = funcs.screenattr(1, 1) + local attr_2 = funcs.screenattr(1, 2) + local attr_3 = funcs.screenattr(1, 3) + local attr_4 = funcs.screenattr(1, 4) + eq(attr_1, attr_2) + eq(attr_1, attr_3) + neq(attr_1, attr_4) + end) + + it('screenchar()', function() + eq(97, funcs.screenchar(1, 1)) + eq(97, funcs.screenchar(1, 2)) + eq(98, funcs.screenchar(1, 3)) + eq(99, funcs.screenchar(1, 4)) + end) + + it('screenchars()', function() + eq({ 97 }, funcs.screenchars(1, 1)) + eq({ 97 }, funcs.screenchars(1, 2)) + eq({ 98 }, funcs.screenchars(1, 3)) + eq({ 99 }, funcs.screenchars(1, 4)) + end) + + it('screenstring()', function() + eq('a', funcs.screenstring(1, 1)) + eq('a', funcs.screenstring(1, 2)) + eq('b', funcs.screenstring(1, 3)) + eq('c', funcs.screenstring(1, 4)) + end) +end) -- cgit From 0b9664f5240be4d9e9d6882fcd398970fd3a9532 Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Tue, 9 Nov 2021 20:22:21 +0600 Subject: fix: make_filter_cmd for :! powershell #15913 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Nvim fails to create tempfile "…/nvim6UJx04/7" when 'shell' is set to pwsh (PowerShell Core). This breaks filtered shell commands ":{range}!". With shell set to cmd, it works. Solution: PowerShell doesn't use "<" for stdin redirection. Instead, use "-RedirectStandardInput". Closes #15913 --- test/functional/vimscript/system_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 9cc6424d31..dd1ac694e7 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -6,6 +6,8 @@ local eq, call, clear, eval, feed_command, feed, nvim = helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command, helpers.feed, helpers.nvim local command = helpers.command +local insert = helpers.insert +local expect = helpers.expect local exc_exec = helpers.exc_exec local iswin = helpers.iswin local os_kill = helpers.os_kill @@ -630,3 +632,29 @@ describe('systemlist()', function() end) end) + +it(':{range}! works with powershell for filter and redirection #16271', function() + clear() + if not helpers.has_powershell() then + pending("not tested; powershell was not found", function() end) + return + end + local screen = Screen.new(500, 8) + screen:attach() + helpers.set_shell_powershell() + insert([[ + 3 + 1 + 4 + 2]]) + feed(':4verbose %!sort') + screen:expect{ + any=[[Executing command: "Start%-Process sort %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait".*4 lines filtered.*Press ENTER or type command to continue]] + } + feed('') + expect([[ + 1 + 2 + 3 + 4]]) +end) -- cgit From f977f9445f7689fc32a136108ff92b3c2137968c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 22 Jun 2022 05:51:52 -0700 Subject: refactor(tests): introduce testprg() Also: - Add a describe('shell :!') section to system_spec. - Make the test for #16271 work on systems without powershell. --- test/functional/vimscript/let_spec.lua | 4 +- test/functional/vimscript/system_spec.lua | 74 +++++++++++++++---------------- 2 files changed, 37 insertions(+), 41 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 6e93655e32..85c9c690f9 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -7,7 +7,7 @@ local eval = helpers.eval local meths = helpers.meths local exec_capture = helpers.exec_capture local source = helpers.source -local nvim_dir = helpers.nvim_dir +local testprg = helpers.testprg before_each(clear) @@ -59,7 +59,7 @@ describe(':let', function() end) it("multibyte env var to child process #8398 #9267", function() - local cmd_get_child_env = "let g:env_from_child = system(['"..nvim_dir.."/printenv-test', 'NVIM_TEST_LET'])" + local cmd_get_child_env = ("let g:env_from_child = system(['%s', 'NVIM_TEST_LET'])"):format(testprg('printenv-test')) command("let $NVIM_TEST_LET = 'AìaB'") command(cmd_get_child_env) eq(eval('$NVIM_TEST_LET'), eval('g:env_from_child')) diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index dd1ac694e7..49b48fecd9 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local assert_alive = helpers.assert_alive -local nvim_dir = helpers.nvim_dir +local testprg = helpers.testprg local eq, call, clear, eval, feed_command, feed, nvim = helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command, helpers.feed, helpers.nvim @@ -32,10 +32,6 @@ describe('system()', function() before_each(clear) describe('command passed as a List', function() - local function printargs_path() - return nvim_dir..'/printargs-test' .. (iswin() and '.exe' or '') - end - it('throws error if cmd[0] is not executable', function() eq("Vim:E475: Invalid value for argument cmd: 'this-should-not-exist' is not executable", pcall_err(call, 'system', { 'this-should-not-exist' })) @@ -68,16 +64,16 @@ describe('system()', function() it('quotes arguments correctly #5280', function() local out = call('system', - { printargs_path(), [[1]], [[2 "3]], [[4 ' 5]], [[6 ' 7']] }) + { testprg('printargs-test'), [[1]], [[2 "3]], [[4 ' 5]], [[6 ' 7']] }) eq(0, eval('v:shell_error')) eq([[arg1=1;arg2=2 "3;arg3=4 ' 5;arg4=6 ' 7';]], out) - out = call('system', { printargs_path(), [['1]], [[2 "3]] }) + out = call('system', { testprg('printargs-test'), [['1]], [[2 "3]] }) eq(0, eval('v:shell_error')) eq([[arg1='1;arg2=2 "3;]], out) - out = call('system', { printargs_path(), "A\nB" }) + out = call('system', { testprg('printargs-test'), "A\nB" }) eq(0, eval('v:shell_error')) eq("arg1=A\nB;", out) end) @@ -169,7 +165,7 @@ describe('system()', function() end end) - it('works with powershell', function() + it('with powershell', function() helpers.set_shell_powershell() eq('a\nb\n', eval([[system('Write-Output a b')]])) eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]])) @@ -177,12 +173,11 @@ describe('system()', function() end) end - it('works with powershell w/ UTF-8 text (#13713)', function() + it('powershell w/ UTF-8 text #13713', function() if not helpers.has_powershell() then pending("not tested; powershell was not found", function() end) return end - -- Should work with recommended config used in helper helpers.set_shell_powershell() eq('ああ\n', eval([[system('Write-Output "ああ"')]])) -- Sanity test w/ default encoding @@ -432,7 +427,7 @@ describe('system()', function() end) it("with a program that doesn't close stdout will exit properly after passing input", function() - local out = eval(string.format("system('%s', 'clip-data')", nvim_dir..'/streams-test')) + local out = eval(string.format("system('%s', 'clip-data')", testprg('streams-test'))) assert(out:sub(0, 5) == 'pid: ', out) os_kill(out:match("%d+")) end) @@ -611,17 +606,16 @@ describe('systemlist()', function() end) it("with a program that doesn't close stdout will exit properly after passing input", function() - local out = eval(string.format("systemlist('%s', 'clip-data')", nvim_dir..'/streams-test')) + local out = eval(string.format("systemlist('%s', 'clip-data')", testprg('streams-test'))) assert(out[1]:sub(0, 5) == 'pid: ', out) os_kill(out[1]:match("%d+")) end) - it('works with powershell w/ UTF-8 text (#13713)', function() + it('powershell w/ UTF-8 text #13713', function() if not helpers.has_powershell() then pending("not tested; powershell was not found", function() end) return end - -- Should work with recommended config used in helper helpers.set_shell_powershell() eq({iswin() and 'あ\r' or 'あ'}, eval([[systemlist('Write-Output あ')]])) -- Sanity test w/ default encoding @@ -633,28 +627,30 @@ describe('systemlist()', function() end) -it(':{range}! works with powershell for filter and redirection #16271', function() - clear() - if not helpers.has_powershell() then - pending("not tested; powershell was not found", function() end) - return - end - local screen = Screen.new(500, 8) - screen:attach() - helpers.set_shell_powershell() - insert([[ - 3 - 1 - 4 - 2]]) - feed(':4verbose %!sort') - screen:expect{ - any=[[Executing command: "Start%-Process sort %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait".*4 lines filtered.*Press ENTER or type command to continue]] - } - feed('') - expect([[ - 1 - 2 - 3 - 4]]) +describe('shell :!', function() + before_each(clear) + + it(':{range}! with powershell filter/redirect #16271', function() + local screen = Screen.new(500, 8) + screen:attach() + local found = helpers.set_shell_powershell(true) + insert([[ + 3 + 1 + 4 + 2]]) + feed(':4verbose %!sort') + screen:expect{ + any=[[Executing command: .?Start%-Process sort %-RedirectStandardInput .* %-RedirectStandardOutput .* %-NoNewWindow %-Wait]] + } + feed('') + if found then + -- Not using fake powershell, so we can test the result. + expect([[ + 1 + 2 + 3 + 4]]) + end + end) end) -- cgit From e2f9d0332b673431d79f0db9386956055674006b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Jun 2022 07:03:06 +0200 Subject: test: use "python3" to avoid skipped test #19106 Problem: The "calls executable in $PATH" is skipped on some CI jobs because "python" is not found. Solution: Use "python3" instead. --- test/functional/vimscript/system_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 49b48fecd9..c915556c57 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -79,8 +79,8 @@ describe('system()', function() end) it('calls executable in $PATH', function() - if 0 == eval("executable('python')") then pending("missing `python`") end - eq("foo\n", eval([[system(['python', '-c', 'print("foo")'])]])) + if 0 == eval("executable('python3')") then pending("missing `python3`") end + eq("foo\n", eval([[system(['python3', '-c', 'print("foo")'])]])) eq(0, eval('v:shell_error')) end) @@ -175,7 +175,7 @@ describe('system()', function() it('powershell w/ UTF-8 text #13713', function() if not helpers.has_powershell() then - pending("not tested; powershell was not found", function() end) + pending("powershell not found", function() end) return end helpers.set_shell_powershell() @@ -613,7 +613,7 @@ describe('systemlist()', function() it('powershell w/ UTF-8 text #13713', function() if not helpers.has_powershell() then - pending("not tested; powershell was not found", function() end) + pending("powershell not found", function() end) return end helpers.set_shell_powershell() -- cgit From f50135a32e11c535e1dc3a8e9460c5b4e640ee86 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 30 Jun 2022 13:16:46 +0200 Subject: feat: stdpath('run'), /tmp/nvim.user/ #18993 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Since c57f6b28d71d #8519, sockets are created in ~/.local/… but XDG spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which implies that XDG_STATE_DIR is potentially non-local. - Not easy to inspect Nvim-created temp files (for debugging etc). Solution: - Store sockets in stdpath('run') ($XDG_RUNTIME_DIR). - Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims. - Make ok() actually useful. - Introduce assert_nolog(). closes #3517 closes #17093 --- test/functional/vimscript/server_spec.lua | 17 ++++++++++++++++- test/functional/vimscript/timer_spec.lua | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua index ea07be231d..6e95459630 100644 --- a/test/functional/vimscript/server_spec.lua +++ b/test/functional/vimscript/server_spec.lua @@ -5,6 +5,7 @@ local iswin = helpers.iswin local ok = helpers.ok local matches = helpers.matches local pcall_err = helpers.pcall_err +local mkdir = helpers.mkdir local function clear_serverlist() for _, server in pairs(funcs.serverlist()) do @@ -13,9 +14,19 @@ local function clear_serverlist() end describe('server', function() - before_each(clear) + it('serverstart() stores sockets in $XDG_RUNTIME_DIR', function() + local dir = 'Xtest_xdg_run' + mkdir(dir) + clear({ env={ XDG_RUNTIME_DIR=dir } }) + matches(dir, funcs.stdpath('run')) + if not iswin() then + matches(dir, funcs.serverstart()) + end + end) + it('serverstart(), serverstop() does not set $NVIM', function() + clear() local s = eval('serverstart()') assert(s ~= nil and s:len() > 0, "serverstart() returned empty") eq('', eval('$NVIM')) @@ -34,6 +45,7 @@ describe('server', function() end) it('sets v:servername at startup or if all servers were stopped', function() + clear() local initial_server = meths.get_vvar('servername') assert(initial_server ~= nil and initial_server:len() > 0, 'v:servername was not initialized') @@ -62,11 +74,13 @@ describe('server', function() end) it('serverstop() returns false for invalid input', function() + clear() eq(0, eval("serverstop('')")) eq(0, eval("serverstop('bogus-socket-name')")) end) it('parses endpoints', function() + clear() clear_serverlist() eq({}, funcs.serverlist()) @@ -111,6 +125,7 @@ describe('server', function() end) it('serverlist() returns the list of servers', function() + clear() -- There should already be at least one server. local n = eval('len(serverlist())') diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 20f2afb20f..5463cfb234 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -96,7 +96,7 @@ describe('timers', function() nvim_async("command", "let g:val = 0 | let g:c = getchar()") retry(nil, nil, function() local val = eval("g:val") - ok(val >= 2, "expected >= 2, got: "..tostring(val)) + ok(val >= 2, '>= 2', tostring(val)) eq(0, eval("getchar(1)")) end) feed("c") -- cgit From 664efa497e4e3d79d2e4ab486acbf1471b2389b0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 7 Jul 2022 04:47:18 +0800 Subject: vim-patch:8.2.0614: get ml_get error when deleting a line in 'completefunc' (#19244) Problem: Get ml_get error when deleting a line in 'completefunc'. (Yegappan Lakshmanan) Solution: Lock the text while evaluating 'completefunc'. https://github.com/vim/vim/commit/ff06f283e3e4b3ec43012dd3b83f8454c98f6639 Fix a mistake in the porting of patch 8.1.0098. Cherry-pick Test_run_excmd_with_text_locked() from patch 8.2.0270. Cherry-pick test_gf.vim changes from patch 8.2.0369. Cherry-pick message change from later patches. --- test/functional/vimscript/api_functions_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index d07e74d40e..8ca245f61a 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -49,7 +49,8 @@ describe('eval-API', function() it('cannot change texts if textlocked', function() command("autocmd TextYankPost ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])") - eq('Vim(call):E5555: API call: E523: Not allowed here', pcall_err(command, "normal! yy")) + eq('Vim(call):E5555: API call: E565: Not allowed to change text or change window', + pcall_err(command, "normal! yy")) end) it("use buffer numbers and windows ids as handles", function() -- cgit From b93cb481a20972c6af330de3e8974f641bccb355 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 14 Jul 2022 14:47:25 +0800 Subject: feat(eval)!: input() support any type for "cancelreturn" in a dict (#19357) --- test/functional/vimscript/input_spec.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index 14c02f9eb2..554d15e550 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -9,6 +9,7 @@ local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec local nvim_async = helpers.nvim_async +local NIL = helpers.NIL local screen @@ -200,6 +201,15 @@ describe('input()', function() feed(':let var = input({"cancelreturn": "BAR"})') feed('') eq('BAR', meths.get_var('var')) + feed(':let var = input({"cancelreturn": []})') + feed('') + eq({}, meths.get_var('var')) + feed(':let var = input({"cancelreturn": v:false})') + feed('') + eq(false, meths.get_var('var')) + feed(':let var = input({"cancelreturn": v:null})') + feed('') + eq(NIL, meths.get_var('var')) end) it('supports default string', function() feed(':let var = input("", "DEF1")') @@ -219,8 +229,6 @@ describe('input()', function() exc_exec('call input("", "", [])')) eq('Vim(call):E730: using List as a String', exc_exec('call input({"prompt": []})')) - eq('Vim(call):E730: using List as a String', - exc_exec('call input({"cancelreturn": []})')) eq('Vim(call):E730: using List as a String', exc_exec('call input({"default": []})')) eq('Vim(call):E730: using List as a String', @@ -417,8 +425,6 @@ describe('inputdialog()', function() exc_exec('call inputdialog("", "", [])')) eq('Vim(call):E730: using List as a String', exc_exec('call inputdialog({"prompt": []})')) - eq('Vim(call):E730: using List as a String', - exc_exec('call inputdialog({"cancelreturn": []})')) eq('Vim(call):E730: using List as a String', exc_exec('call inputdialog({"default": []})')) eq('Vim(call):E730: using List as a String', -- cgit From 711a6a915767a97300aba76fb9d79b9784bc76ce Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Jul 2022 14:54:31 +0800 Subject: fix(ex_cmds): correct flags for :const (#19387) --- test/functional/vimscript/let_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 85c9c690f9..ca1b5e8907 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -5,6 +5,7 @@ local clear = helpers.clear local command = helpers.command local eval = helpers.eval local meths = helpers.meths +local exec = helpers.exec local exec_capture = helpers.exec_capture local source = helpers.source local testprg = helpers.testprg @@ -91,3 +92,19 @@ describe(':let', function() eq(1, eval('1')) end) end) + +describe(':let and :const', function() + it('have the same output when called without arguments', function() + eq(exec_capture('let'), exec_capture('const')) + end) + + it('can be used in sandbox', function() + exec([[ + func Func() + let l:foo = 'foo' + const l:bar = 'bar' + endfunc + sandbox call Func() + ]]) + end) +end) -- cgit From 1b462705d049fa0cf2bb99bae9112b84abea8d5a Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Mon, 18 Jul 2022 06:00:08 +0600 Subject: fix(windows):exepath, stdpath return wrong slashes #19111 exepath and stdpath should respect shellslash and return path with proper file separator. Closes #13787 --- test/functional/vimscript/executable_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/vimscript') 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..')')) -- cgit