mirror of
https://github.com/neovim/neovim.git
synced 2025-11-21 17:46:30 +00:00
test: verify that v:shell_error is set by system()/systemlist()
This commit is contained in:
@@ -23,6 +23,15 @@ end
|
||||
describe('system()', function()
|
||||
before_each(clear)
|
||||
|
||||
it('sets the v:shell_error variable', 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'))
|
||||
end)
|
||||
|
||||
describe('passing no input', function()
|
||||
it('returns the program output', function()
|
||||
eq("echoed", eval('system("echo -n echoed")'))
|
||||
@@ -83,6 +92,15 @@ describe('systemlist()', function()
|
||||
-- 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'))
|
||||
end)
|
||||
|
||||
describe('passing string with linefeed characters as input', function()
|
||||
it('splits the output on linefeed characters', function()
|
||||
eq({'abc', 'def', 'ghi'}, eval([[systemlist("cat -", "abc\ndef\nghi")]]))
|
||||
|
||||
Reference in New Issue
Block a user