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/system_spec.lua') 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 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/system_spec.lua') 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 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/system_spec.lua') 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/system_spec.lua | 74 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 39 deletions(-) (limited to 'test/functional/vimscript/system_spec.lua') 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/system_spec.lua') 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