mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
test: "!:&" works with powershell #11201
Removed 'echo' alias because it does not behave like POSIX echo.
This commit is contained in:

committed by
Justin M. Keyes

parent
b772b86d2b
commit
a7fc2f3f64
@@ -84,7 +84,7 @@ describe('system()', function()
|
||||
|
||||
it('does NOT run in shell', function()
|
||||
if iswin() then
|
||||
eq("%PATH%\n", eval("system(['powershell', '-NoProfile', '-NoLogo', '-ExecutionPolicy', 'RemoteSigned', '-Command', 'echo', '%PATH%'])"))
|
||||
eq("%PATH%\n", eval("system(['powershell', '-NoProfile', '-NoLogo', '-ExecutionPolicy', 'RemoteSigned', '-Command', 'Write-Output', '%PATH%'])"))
|
||||
else
|
||||
eq("* $PATH %PATH%\n", eval("system(['echo', '*', '$PATH', '%PATH%'])"))
|
||||
end
|
||||
@@ -133,7 +133,7 @@ describe('system()', function()
|
||||
eval([[system('"ping" "-n" "1" "127.0.0.1"')]])
|
||||
eq(0, eval('v:shell_error'))
|
||||
eq('"a b"\n', eval([[system('cmd /s/c "cmd /s/c "cmd /s/c "echo "a b""""')]]))
|
||||
eq('"a b"\n', eval([[system('powershell -NoProfile -NoLogo -ExecutionPolicy RemoteSigned -Command echo ''\^"a b\^"''')]]))
|
||||
eq('"a b"\n', eval([[system('powershell -NoProfile -NoLogo -ExecutionPolicy RemoteSigned -Command Write-Output ''\^"a b\^"''')]]))
|
||||
end
|
||||
|
||||
it('with shell=cmd.exe', function()
|
||||
@@ -169,9 +169,9 @@ describe('system()', function()
|
||||
|
||||
it('works with powershell', function()
|
||||
helpers.set_shell_powershell()
|
||||
eq('a\nb\n', eval([[system('echo a b')]]))
|
||||
eq('a\nb\n', eval([[system('Write-Output a b')]]))
|
||||
eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]]))
|
||||
eq('a b\n', eval([[system('echo "a b"')]]))
|
||||
eq('a b\n', eval([[system('Write-Output "a b"')]]))
|
||||
end)
|
||||
end
|
||||
|
||||
|
@@ -502,14 +502,10 @@ end
|
||||
|
||||
function module.set_shell_powershell()
|
||||
local shell = iswin() and 'powershell' or 'pwsh'
|
||||
if not module.eval('executable("'..shell..'")') then
|
||||
error(shell..' is not executable')
|
||||
end
|
||||
local aliases = iswin() and {'cat', 'sleep'} or {}
|
||||
local cmd = ''
|
||||
for _, alias in ipairs(aliases) do
|
||||
cmd = cmd .. 'Remove-Item -Force alias:' .. alias .. ';'
|
||||
end
|
||||
assert(module.eval('executable("'..shell..'")'))
|
||||
local cmd = 'Remove-Item -Force '..table.concat(iswin()
|
||||
and {'alias:cat', 'alias:echo', 'alias:sleep'}
|
||||
or {'alias:echo'}, ',')..';'
|
||||
module.source([[
|
||||
let &shell = ']]..shell..[['
|
||||
set shellquote= shellpipe=\| shellxquote=
|
||||
|
@@ -236,14 +236,18 @@ describe("shell command :!", function()
|
||||
set_shell_powershell()
|
||||
local screen = Screen.new(30, 4)
|
||||
screen:attach()
|
||||
feed_command([[!'echo $a']])
|
||||
screen:expect{any='\necho %$a', timeout=10000}
|
||||
feed_command([[!$a = 1; echo '$a']])
|
||||
feed_command([[!'Write-Output $a']])
|
||||
screen:expect{any='\nWrite%-Output %$a', timeout=10000}
|
||||
feed_command([[!$a = 1; Write-Output '$a']])
|
||||
screen:expect{any='\n%$a', timeout=10000}
|
||||
feed_command([[!"echo $a"]])
|
||||
screen:expect{any='\necho', timeout=10000}
|
||||
feed_command([[!$a = 1; echo "$a"]])
|
||||
feed_command([[!"Write-Output $a"]])
|
||||
screen:expect{any='\nWrite%-Output', timeout=10000}
|
||||
feed_command([[!$a = 1; Write-Output "$a"]])
|
||||
screen:expect{any='\n1', timeout=10000}
|
||||
feed_command(iswin()
|
||||
and [[!& 'C:\\Windows\\system32\\cmd.exe' /c 'echo $a']]
|
||||
or [[!& '/bin/sh' -c 'echo ''$a''']])
|
||||
screen:expect{any='\n%$a', timeout=10000}
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user