vim-patch:8.2.3061: testing the shell option is incomplete and spread out (#29090)

Problem:    Testing the shell option is incomplete and spread out.
Solution:   Move shell tests to one file and increase coverage. (Yegappan
            Lakshmanan, closes vim/vim#8464)

054794c20f

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq 2024-05-30 14:39:48 +08:00 committed by GitHub
parent f55767afe2
commit 40679c764a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 77 deletions

View File

@ -2143,54 +2143,6 @@ func Test_balloon_show()
endif endif
endfunc endfunc
func Test_shellescape()
let save_shell = &shell
set shell=bash
call assert_equal("'text'", shellescape('text'))
call assert_equal("'te\"xt'", 'te"xt'->shellescape())
call assert_equal("'te'\\''xt'", shellescape("te'xt"))
call assert_equal("'te%xt'", shellescape("te%xt"))
call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
call assert_equal("'te#xt'", shellescape("te#xt"))
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
call assert_equal("'te!xt'", shellescape("te!xt"))
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
call assert_equal("'te\nxt'", shellescape("te\nxt"))
call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
set shell=tcsh
call assert_equal("'te\\!xt'", shellescape("te!xt"))
call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1))
call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
set shell=fish
call assert_equal("'text'", shellescape('text'))
call assert_equal("'te\"xt'", shellescape('te"xt'))
call assert_equal("'te'\\''xt'", shellescape("te'xt"))
call assert_equal("'te%xt'", shellescape("te%xt"))
call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
call assert_equal("'te#xt'", shellescape("te#xt"))
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
call assert_equal("'te!xt'", shellescape("te!xt"))
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
call assert_equal("'te\\\\xt'", shellescape("te\\xt"))
call assert_equal("'te\\\\xt'", shellescape("te\\xt", 1))
call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt"))
call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt", 1))
call assert_equal("'te\\\\!xt'", shellescape("te\\!xt"))
call assert_equal("'te\\\\\\!xt'", shellescape("te\\!xt", 1))
call assert_equal("'te\\\\%xt'", shellescape("te\\%xt"))
call assert_equal("'te\\\\\\%xt'", shellescape("te\\%xt", 1))
call assert_equal("'te\\\\#xt'", shellescape("te\\#xt"))
call assert_equal("'te\\\\\\#xt'", shellescape("te\\#xt", 1))
let &shell = save_shell
endfunc
func Test_setbufvar_options() func Test_setbufvar_options()
" This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the " This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
" window layout and cursor position. " window layout and cursor position.

View File

@ -1400,35 +1400,6 @@ func Test_buftype()
bwipe! bwipe!
endfunc endfunc
" Test for the 'shell' option
func Test_shell()
throw 'Skipped: Nvim does not have :shell'
CheckUnix
let save_shell = &shell
set shell=
let caught_e91 = 0
try
shell
catch /E91:/
let caught_e91 = 1
endtry
call assert_equal(1, caught_e91)
let &shell = save_shell
endfunc
" Test for the 'shellquote' option
func Test_shellquote()
CheckUnix
set shellquote=#
set verbose=20
redir => v
silent! !echo Hello
redir END
set verbose&
set shellquote&
call assert_match(': "#echo Hello#"', v)
endfunc
" Test for the 'rightleftcmd' option " Test for the 'rightleftcmd' option
func Test_rightleftcmd() func Test_rightleftcmd()
CheckFeature rightleft CheckFeature rightleft

View File

@ -128,6 +128,29 @@ func Test_shellescape()
call assert_equal("'te\\\nxt'", shellescape("te\nxt")) call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1)) call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
set shell=fish
call assert_equal("'text'", shellescape('text'))
call assert_equal("'te\"xt'", shellescape('te"xt'))
call assert_equal("'te'\\''xt'", shellescape("te'xt"))
call assert_equal("'te%xt'", shellescape("te%xt"))
call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
call assert_equal("'te#xt'", shellescape("te#xt"))
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
call assert_equal("'te!xt'", shellescape("te!xt"))
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
call assert_equal("'te\\\\xt'", shellescape("te\\xt"))
call assert_equal("'te\\\\xt'", shellescape("te\\xt", 1))
call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt"))
call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt", 1))
call assert_equal("'te\\\\!xt'", shellescape("te\\!xt"))
call assert_equal("'te\\\\\\!xt'", shellescape("te\\!xt", 1))
call assert_equal("'te\\\\%xt'", shellescape("te\\%xt"))
call assert_equal("'te\\\\\\%xt'", shellescape("te\\%xt", 1))
call assert_equal("'te\\\\#xt'", shellescape("te\\#xt"))
call assert_equal("'te\\\\\\#xt'", shellescape("te\\#xt", 1))
let &shell = save_shell let &shell = save_shell
endfunc endfunc