mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
win/test: Enable more system() tests
This commit is contained in:
parent
f7611d74e7
commit
799443c994
@ -94,17 +94,26 @@ describe('system()', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
it('sets v:shell_error', function()
|
it('sets v:shell_error', function()
|
||||||
eval([[system("sh -c 'exit'")]])
|
if helpers.os_name() == 'windows' then
|
||||||
eq(0, eval('v:shell_error'))
|
eval([[system("cmd.exe /c exit")]])
|
||||||
eval([[system("sh -c 'exit 1'")]])
|
eq(0, eval('v:shell_error'))
|
||||||
eq(1, eval('v:shell_error'))
|
eval([[system("cmd.exe /c exit 1")]])
|
||||||
eval([[system("sh -c 'exit 5'")]])
|
eq(1, eval('v:shell_error'))
|
||||||
eq(5, eval('v:shell_error'))
|
eval([[system("cmd.exe /c exit 5")]])
|
||||||
eval([[system('this-should-not-exist')]])
|
eq(5, eval('v:shell_error'))
|
||||||
eq(127, eval('v:shell_error'))
|
eval([[system('this-should-not-exist')]])
|
||||||
|
eq(1, eval('v:shell_error'))
|
||||||
|
else
|
||||||
|
eval([[system("sh -c 'exit'")]])
|
||||||
|
eq(0, eval('v:shell_error'))
|
||||||
|
eval([[system("sh -c 'exit 1'")]])
|
||||||
|
eq(1, eval('v:shell_error'))
|
||||||
|
eval([[system("sh -c 'exit 5'")]])
|
||||||
|
eq(5, eval('v:shell_error'))
|
||||||
|
eval([[system('this-should-not-exist')]])
|
||||||
|
eq(127, eval('v:shell_error'))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('executes shell function if passed a string', function()
|
describe('executes shell function if passed a string', function()
|
||||||
@ -120,6 +129,15 @@ describe('system()', function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('escapes inner double quotes #6329', function()
|
||||||
|
if helpers.os_name() == 'windows' then
|
||||||
|
-- In Windows cmd.exe's echo prints the quotes
|
||||||
|
eq('""\n', eval([[system('echo ""')]]))
|
||||||
|
else
|
||||||
|
eq('\n', eval([[system('echo ""')]]))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
it('`echo` and waits for its return', function()
|
it('`echo` and waits for its return', function()
|
||||||
feed(':call system("echo")<cr>')
|
feed(':call system("echo")<cr>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -180,7 +198,11 @@ describe('system()', function()
|
|||||||
|
|
||||||
describe('passing no input', function()
|
describe('passing no input', function()
|
||||||
it('returns the program output', function()
|
it('returns the program output', function()
|
||||||
eq("echoed", eval('system("echo -n echoed")'))
|
if helpers.os_name() == 'windows' then
|
||||||
|
eq("echoed\n", eval('system("echo echoed")'))
|
||||||
|
else
|
||||||
|
eq("echoed", eval('system("echo -n echoed")'))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
it('to backgrounded command does not crash', function()
|
it('to backgrounded command does not crash', function()
|
||||||
-- This is indeterminate, just exercise the codepath. May get E5677.
|
-- This is indeterminate, just exercise the codepath. May get E5677.
|
||||||
@ -277,21 +299,30 @@ describe('system()', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('systemlist()', function()
|
describe('systemlist()', function()
|
||||||
-- Similar to `system()`, but returns List instead of String.
|
-- Similar to `system()`, but returns List instead of String.
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('sets the v:shell_error variable', function()
|
it('sets the v:shell_error variable', function()
|
||||||
eval([[systemlist("sh -c 'exit'")]])
|
if helpers.os_name() == 'windows' then
|
||||||
eq(0, eval('v:shell_error'))
|
eval([[systemlist("cmd.exe /c exit")]])
|
||||||
eval([[systemlist("sh -c 'exit 1'")]])
|
eq(0, eval('v:shell_error'))
|
||||||
eq(1, eval('v:shell_error'))
|
eval([[systemlist("cmd.exe /c exit 1")]])
|
||||||
eval([[systemlist("sh -c 'exit 5'")]])
|
eq(1, eval('v:shell_error'))
|
||||||
eq(5, eval('v:shell_error'))
|
eval([[systemlist("cmd.exe /c exit 5")]])
|
||||||
eval([[systemlist('this-should-not-exist')]])
|
eq(5, eval('v:shell_error'))
|
||||||
eq(127, eval('v:shell_error'))
|
eval([[systemlist('this-should-not-exist')]])
|
||||||
|
eq(1, eval('v:shell_error'))
|
||||||
|
else
|
||||||
|
eval([[systemlist("sh -c 'exit'")]])
|
||||||
|
eq(0, eval('v:shell_error'))
|
||||||
|
eval([[systemlist("sh -c 'exit 1'")]])
|
||||||
|
eq(1, eval('v:shell_error'))
|
||||||
|
eval([[systemlist("sh -c 'exit 5'")]])
|
||||||
|
eq(5, eval('v:shell_error'))
|
||||||
|
eval([[systemlist('this-should-not-exist')]])
|
||||||
|
eq(127, eval('v:shell_error'))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('exectues shell function', function()
|
describe('exectues shell function', function()
|
||||||
@ -389,6 +420,7 @@ describe('systemlist()', function()
|
|||||||
after_each(delete_file(fname))
|
after_each(delete_file(fname))
|
||||||
|
|
||||||
it('replaces NULs by newline characters', function()
|
it('replaces NULs by newline characters', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")'))
|
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -348,7 +348,7 @@ end
|
|||||||
local function set_shell_powershell()
|
local function set_shell_powershell()
|
||||||
source([[
|
source([[
|
||||||
set shell=powershell shellquote=\" shellpipe=\| shellredir=>
|
set shell=powershell shellquote=\" shellpipe=\| shellredir=>
|
||||||
set shellcmdflag=\ -ExecutionPolicy\ RemoteSigned\ -Command
|
set shellcmdflag=\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
|
||||||
let &shellxquote=' '
|
let &shellxquote=' '
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user