aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_system.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/testdir/test_system.vim')
-rw-r--r--src/nvim/testdir/test_system.vim54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim
index d3c0594c03..424cb4abd0 100644
--- a/src/nvim/testdir/test_system.vim
+++ b/src/nvim/testdir/test_system.vim
@@ -1,5 +1,8 @@
" Tests for system() and systemlist()
+source shared.vim
+source check.vim
+
function! Test_System()
if !executable('echo') || !executable('cat') || !executable('wc')
return
@@ -88,3 +91,54 @@ function! Test_system_exmode()
let a = system(v:progpath. cmd)
call assert_notequal(0, v:shell_error)
endfunc
+
+func Test_system_with_shell_quote()
+ throw 'skipped: enable after porting method patches'
+ CheckMSWindows
+
+ call mkdir('Xdir with spaces', 'p')
+ call system('copy "%COMSPEC%" "Xdir with spaces\cmd.exe"')
+
+ let shell_save = &shell
+ let shellxquote_save = &shellxquote
+ try
+ " Set 'shell' always needs noshellslash.
+ let shellslash_save = &shellslash
+ set noshellslash
+ let shell_tests = [
+ \ expand('$COMSPEC'),
+ \ '"' . fnamemodify('Xdir with spaces\cmd.exe', ':p') . '"',
+ \]
+ let &shellslash = shellslash_save
+
+ let sxq_tests = ['', '(', '"']
+
+ " Matrix tests: 'shell' * 'shellxquote'
+ for shell in shell_tests
+ let &shell = shell
+ for sxq in sxq_tests
+ let &shellxquote = sxq
+
+ let msg = printf('shell=%s shellxquote=%s', &shell, &shellxquote)
+
+ try
+ let out = 'echo 123'->system()
+ catch
+ call assert_report(printf('%s: %s', msg, v:exception))
+ continue
+ endtry
+
+ " On Windows we may get a trailing space and CR.
+ if out != "123 \n"
+ call assert_equal("123\n", out, msg)
+ endif
+
+ endfor
+ endfor
+
+ finally
+ let &shell = shell_save
+ let &shellxquote = shellxquote_save
+ call delete('Xdir with spaces', 'rf')
+ endtry
+endfunc