mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
win/test: Enable more system() tests
This commit is contained in:

committed by
Justin M. Keyes

parent
f7611d74e7
commit
799443c994
@@ -94,17 +94,26 @@ describe('system()', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
|
||||
it('sets v:shell_error', function()
|
||||
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'))
|
||||
if helpers.os_name() == 'windows' then
|
||||
eval([[system("cmd.exe /c exit")]])
|
||||
eq(0, eval('v:shell_error'))
|
||||
eval([[system("cmd.exe /c exit 1")]])
|
||||
eq(1, eval('v:shell_error'))
|
||||
eval([[system("cmd.exe /c exit 5")]])
|
||||
eq(5, 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)
|
||||
|
||||
describe('executes shell function if passed a string', function()
|
||||
@@ -120,6 +129,15 @@ describe('system()', function()
|
||||
screen:detach()
|
||||
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()
|
||||
feed(':call system("echo")<cr>')
|
||||
screen:expect([[
|
||||
@@ -180,7 +198,11 @@ describe('system()', function()
|
||||
|
||||
describe('passing no input', 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)
|
||||
it('to backgrounded command does not crash', function()
|
||||
-- This is indeterminate, just exercise the codepath. May get E5677.
|
||||
@@ -277,21 +299,30 @@ describe('system()', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
|
||||
describe('systemlist()', function()
|
||||
-- Similar to `system()`, but returns List instead of String.
|
||||
before_each(clear)
|
||||
|
||||
it('sets the v:shell_error variable', function()
|
||||
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'))
|
||||
if helpers.os_name() == 'windows' then
|
||||
eval([[systemlist("cmd.exe /c exit")]])
|
||||
eq(0, eval('v:shell_error'))
|
||||
eval([[systemlist("cmd.exe /c exit 1")]])
|
||||
eq(1, eval('v:shell_error'))
|
||||
eval([[systemlist("cmd.exe /c exit 5")]])
|
||||
eq(5, 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)
|
||||
|
||||
describe('exectues shell function', function()
|
||||
@@ -389,6 +420,7 @@ describe('systemlist()', function()
|
||||
after_each(delete_file(fname))
|
||||
|
||||
it('replaces NULs by newline characters', function()
|
||||
if helpers.pending_win32(pending) then return end
|
||||
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")'))
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user