diff options
author | Rui Abreu Ferreira <rap-ep@gmx.com> | 2017-03-25 22:47:38 +0000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-12 02:10:33 +0200 |
commit | 799443c9942fa145320d9cc7c4638bdaa8c8d67a (patch) | |
tree | 9d3ce8ca52af9d052938e6185af2efb576aa9070 | |
parent | f7611d74e73329a4192666ff59911ff214f462ab (diff) | |
download | rneovim-799443c9942fa145320d9cc7c4638bdaa8c8d67a.tar.gz rneovim-799443c9942fa145320d9cc7c4638bdaa8c8d67a.tar.bz2 rneovim-799443c9942fa145320d9cc7c4638bdaa8c8d67a.zip |
win/test: Enable more system() tests
-rw-r--r-- | test/functional/eval/system_spec.lua | 74 | ||||
-rw-r--r-- | test/functional/helpers.lua | 2 |
2 files changed, 54 insertions, 22 deletions
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index bf95752e3b..83d8028b56 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -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) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 7edb2381e8..5882758b5a 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -348,7 +348,7 @@ end local function set_shell_powershell() source([[ set shell=powershell shellquote=\" shellpipe=\| shellredir=> - set shellcmdflag=\ -ExecutionPolicy\ RemoteSigned\ -Command + set shellcmdflag=\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command let &shellxquote=' ' ]]) end |