To: vim_dev@googlegroups.com Subject: Patch 8.2.3070 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3070 Problem: Not enough testing for shell use. Solution: Add a bit more testing. (Yegappan Lakshmanan, closes #8469) Files: src/testdir/test_shell.vim, src/testdir/test_startup.vim *** ../vim-8.2.3069/src/testdir/test_shell.vim 2021-06-27 12:07:12.444471041 +0200 --- src/testdir/test_shell.vim 2021-06-27 22:07:14.425296013 +0200 *************** *** 5,13 **** source shared.vim func Test_shell_options() ! " For each shell, the following options are checked: ! " 'shellcmdflag', 'shellpipe', 'shellquote', 'shellredir', 'shellxescape', ! " 'shellxquote' let shells = [] if has('unix') let shells += [['sh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], --- 5,12 ---- source shared.vim func Test_shell_options() ! " The expected value of 'shellcmdflag', 'shellpipe', 'shellquote', ! " 'shellredir', 'shellxescape', 'shellxquote' for the supported shells. let shells = [] if has('unix') let shells += [['sh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], *************** *** 39,44 **** --- 38,45 ---- \ ['tcsh.exe', '-c', '>&', '', '>&', '"&|<>()@^', '"']] endif + " start a new Vim instance with 'shell' set to each of the supported shells + " and check the default shell option settings let after =<< trim END let l = [&shell, &shellcmdflag, &shellpipe, &shellquote] let l += [&shellredir, &shellxescape, &shellxquote] *************** *** 51,56 **** --- 52,58 ---- endif endfor + " Test shellescape() for each of the shells. for e in shells exe 'set shell=' .. e[0] if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' *************** *** 62,69 **** endif call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%#"), e[0]) call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%#", 1), e[0]) endfor ! set shell& call delete('Xtestout') endfunc --- 64,83 ---- endif call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%#"), e[0]) call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%#", 1), e[0]) + + " Try running an external command with the shell. + if executable(e[0]) + " set the shell options for the current 'shell' + let [&shellcmdflag, &shellpipe, &shellquote, &shellredir, + \ &shellxescape, &shellxquote] = e[1:6] + new + r !echo hello + call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0]) + bwipe! + endif endfor ! set shell& shellcmdflag& shellpipe& shellquote& ! set shellredir& shellxescape& shellxquote& call delete('Xtestout') endfunc *************** *** 95,100 **** --- 109,115 ---- call assert_match(': "#echo Hello#"', v) endfunc + " Test for the 'shellescape' option func Test_shellescape() let save_shell = &shell set shell=bash *************** *** 156,159 **** --- 171,196 ---- call delete('Xlog') endfunc + " Test for using the shell set in the $SHELL environment variable + func Test_set_shell() + let after =<< trim [CODE] + call writefile([&shell], "Xtestout") + quit! + [CODE] + + if has('win32') + let $SHELL = 'C:\with space\cmd.exe' + let expected = '"C:\with space\cmd.exe"' + else + let $SHELL = '/bin/with space/sh' + let expected = '/bin/with\ space/sh' + endif + + if RunVimPiped([], after, '', '') + let lines = readfile('Xtestout') + call assert_equal(expected, lines[0]) + endif + call delete('Xtestout') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3069/src/testdir/test_startup.vim 2021-06-16 10:59:32.622998987 +0200 --- src/testdir/test_startup.vim 2021-06-27 22:07:14.425296013 +0200 *************** *** 733,759 **** call delete('Xtestout') endfunc - func Test_set_shell() - let after =<< trim [CODE] - call writefile([&shell], "Xtestout") - quit! - [CODE] - - if has('win32') - let $SHELL = 'C:\with space\cmd.exe' - let expected = '"C:\with space\cmd.exe"' - else - let $SHELL = '/bin/with space/sh' - let expected = '/bin/with\ space/sh' - endif - - if RunVimPiped([], after, '', '') - let lines = readfile('Xtestout') - call assert_equal(expected, lines[0]) - endif - call delete('Xtestout') - endfunc - func Test_progpath() " Tests normally run with "./vim" or "../vim", these must have been expanded " to a full path. --- 733,738 ---- *** ../vim-8.2.3069/src/version.c 2021-06-27 22:03:28.649707714 +0200 --- src/version.c 2021-06-27 22:08:32.941152177 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3070, /**/ -- I started out with nothing, and I still have most of it. -- Michael Davis -- "Tonight Show" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///