summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_cmdline.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-08 16:39:22 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-08 16:39:22 +0100
commit45bbaef0382c5468d9fac511775bd99ea7bf5b84 (patch)
treeabd7687d97b0d9abe4d39d5386245dc521bad206 /src/testdir/test_cmdline.vim
parent2a4c885d54171f68ec2c2d6eb4ae281c7fefb802 (diff)
patch 9.0.0418: manually deleting temp test filesv9.0.0418
Problem: Manually deleting temp test files. Solution: Use the 'D' flag of writefile() and mkdir().
Diffstat (limited to 'src/testdir/test_cmdline.vim')
-rw-r--r--src/testdir/test_cmdline.vim118
1 files changed, 40 insertions, 78 deletions
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 80e82eaeb0..73bdbb4e66 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -20,14 +20,13 @@ func TearDown()
endfunc
func Test_complete_tab()
- call writefile(['testfile'], 'Xtestfile')
+ call writefile(['testfile'], 'Xtestfile', 'D')
call feedkeys(":e Xtest\t\r", "tx")
call assert_equal('testfile', getline(1))
" Pressing <Tab> after '%' completes the current file, also on MS-Windows
call feedkeys(":e %\t\r", "tx")
call assert_equal('e Xtestfile', @:)
- call delete('Xtestfile')
endfunc
func Test_complete_list()
@@ -42,7 +41,7 @@ func Test_complete_list()
" Test for displaying the tail of the completion matches
set wildmode=longest,full
- call mkdir('Xtest')
+ call mkdir('Xtest', 'R')
call writefile([], 'Xtest/a.c')
call writefile([], 'Xtest/a.h')
let g:Sline = ''
@@ -78,12 +77,11 @@ func Test_complete_list()
call assert_equal(':e Xtes[/', g:Sline)
call assert_equal('"e Xtes[/', @:)
- call delete('Xtest', 'rf')
set wildmode&
endfunc
func Test_complete_wildmenu()
- call mkdir('Xwilddir1/Xdir2', 'p')
+ call mkdir('Xwilddir1/Xdir2', 'pR')
call writefile(['testfile1'], 'Xwilddir1/Xtestfile1')
call writefile(['testfile2'], 'Xwilddir1/Xtestfile2')
call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3')
@@ -162,7 +160,6 @@ func Test_complete_wildmenu()
" cleanup
%bwipe
- call delete('Xwilddir1', 'rf')
set nowildmenu
endfunc
@@ -172,7 +169,7 @@ func Test_wildmenu_screendump()
let lines =<< trim [SCRIPT]
set wildmenu hlsearch
[SCRIPT]
- call writefile(lines, 'XTest_wildmenu')
+ call writefile(lines, 'XTest_wildmenu', 'D')
let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8})
call term_sendkeys(buf, ":vim\<Tab>")
@@ -190,7 +187,6 @@ func Test_wildmenu_screendump()
" clean up
call StopVimInTerminal(buf)
- call delete('XTest_wildmenu')
endfunc
func Test_redraw_in_autocmd()
@@ -200,7 +196,7 @@ func Test_redraw_in_autocmd()
set cmdheight=2
autocmd CmdlineChanged * redraw
END
- call writefile(lines, 'XTest_redraw')
+ call writefile(lines, 'XTest_redraw', 'D')
let buf = RunVimInTerminal('-S XTest_redraw', {'rows': 8})
call term_sendkeys(buf, ":for i in range(3)\<CR>")
@@ -212,7 +208,6 @@ func Test_redraw_in_autocmd()
" clean up
call term_sendkeys(buf, "\<CR>")
call StopVimInTerminal(buf)
- call delete('XTest_redraw')
endfunc
func Test_changing_cmdheight()
@@ -221,7 +216,7 @@ func Test_changing_cmdheight()
let lines =<< trim END
set cmdheight=1 laststatus=2
END
- call writefile(lines, 'XTest_cmdheight')
+ call writefile(lines, 'XTest_cmdheight', 'D')
let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8})
call term_sendkeys(buf, ":resize -3\<CR>")
@@ -246,7 +241,6 @@ func Test_changing_cmdheight()
" clean up
call StopVimInTerminal(buf)
- call delete('XTest_cmdheight')
endfunc
func Test_map_completion()
@@ -455,10 +449,9 @@ func Test_getcompletion()
call assert_true(index(l, 'runtest.vim') < 0)
set wildignore&
" Directory name with space character
- call mkdir('Xdir with space')
+ call mkdir('Xdir with space', 'D')
call assert_equal(['Xdir with space/'], getcompletion('Xdir\ w', 'shellcmd'))
call assert_equal(['./Xdir with space/'], getcompletion('./Xdir', 'shellcmd'))
- call delete('Xdir with space', 'd')
let l = getcompletion('ha', 'filetype')
call assert_true(index(l, 'hamster') >= 0)
@@ -581,14 +574,13 @@ func Test_getcompletion()
endif
set tags=Xtags
- call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags')
+ call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags', 'D')
for name in names
let matchcount = len(getcompletion('', name))
call assert_true(matchcount >= 0, 'No matches for ' . name)
endfor
- call delete('Xtags')
set tags&
edit a~b
@@ -633,7 +625,7 @@ func Test_complete_autoload_error()
enddef
echo this will cause an error
END
- call mkdir('Xdir/autoload', 'p')
+ call mkdir('Xdir/autoload', 'pR')
call writefile(lines, 'Xdir/autoload/script.vim')
exe 'set rtp+=' .. getcwd() .. '/Xdir'
@@ -647,7 +639,6 @@ func Test_complete_autoload_error()
call v9.CheckScriptFailure(lines, 'E121: Undefined variable: this')
let &rtp = save_rtp
- call delete('Xdir', 'rf')
endfunc
func Test_fullcommand()
@@ -698,7 +689,7 @@ endfunc
func Test_shellcmd_completion()
let save_path = $PATH
- call mkdir('Xpathdir/Xpathsubdir', 'p')
+ call mkdir('Xpathdir/Xpathsubdir', 'pR')
call writefile([''], 'Xpathdir/Xfile.exe')
call setfperm('Xpathdir/Xfile.exe', 'rwx------')
@@ -714,17 +705,15 @@ func Test_shellcmd_completion()
call insert(expected, 'Xfile.exe')
call assert_equal(expected, actual)
- call delete('Xpathdir', 'rf')
let $PATH = save_path
endfunc
func Test_expand_star_star()
- call mkdir('a/b', 'p')
+ call mkdir('a/b', 'pR')
call writefile(['asdfasdf'], 'a/b/fileXname')
call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
call assert_equal('find a/b/fileXname', @:)
bwipe!
- call delete('a', 'rf')
endfunc
func Test_cmdline_paste()
@@ -832,14 +821,13 @@ func Test_illegal_address1()
endfunc
func Test_illegal_address2()
- call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim')
+ call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim', 'D')
new
source Xtest.vim
" Trigger calling validate_cursor()
diffsp Xtest.vim
quit!
bwipe!
- call delete('Xtest.vim')
endfunc
func Test_mark_from_line_zero()
@@ -1035,14 +1023,13 @@ func Test_cmdline_complete_various()
call assert_equal("\"sI \<C-A>", @:)
" completion for :write command
- call mkdir('Xcwdir')
+ call mkdir('Xcwdir', 'R')
call writefile(['one'], 'Xcwdir/Xfile1')
let save_cwd = getcwd()
cd Xcwdir
call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"w >> Xfile1", @:)
call chdir(save_cwd)
- call delete('Xcwdir', 'rf')
" completion for :w ! and :r ! commands
call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt')
@@ -1125,12 +1112,10 @@ func Test_cmdline_complete_various()
call assert_equal("\"doautocmd BufNew,BufEnter", @:)
" completion of file name in :doautocmd
- call writefile([], 'Xvarfile1')
- call writefile([], 'Xvarfile2')
+ call writefile([], 'Xvarfile1', 'D')
+ call writefile([], 'Xvarfile2', 'D')
call feedkeys(":doautocmd BufEnter Xvarfi\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"doautocmd BufEnter Xvarfile1 Xvarfile2", @:)
- call delete('Xvarfile1')
- call delete('Xvarfile2')
" completion for the :augroup command
augroup XTest.test
@@ -1272,7 +1257,7 @@ endfunc
" Test for 'wildignorecase'
func Test_cmdline_wildignorecase()
CheckUnix
- call writefile([], 'XTEST')
+ call writefile([], 'XTEST', 'D')
set wildignorecase
call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e XTEST', @:)
@@ -1282,7 +1267,6 @@ func Test_cmdline_wildignorecase()
call assert_equal('"e xt', @:)
call assert_equal('XTEST', g:Sline)
set wildignorecase&
- call delete('XTEST')
endfunc
func Test_cmdline_write_alternatefile()
@@ -1408,9 +1392,9 @@ func Test_verbosefile()
let log = readfile('Xlog')
call assert_match("foo\nbar", join(log, "\n"))
call delete('Xlog')
- call mkdir('Xdir')
+
+ call mkdir('Xdir', 'D')
call assert_fails('set verbosefile=Xdir', ['E484:.*Xdir', 'E474:'])
- call delete('Xdir', 'd')
endfunc
func Test_verbose_option()
@@ -1421,7 +1405,7 @@ func Test_verbose_option()
call feedkeys("\r", 't') " for the hit-enter prompt
set verbose=20
[SCRIPT]
- call writefile(lines, 'XTest_verbose')
+ call writefile(lines, 'XTest_verbose', 'D')
let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12})
call TermWait(buf, 50)
@@ -1430,7 +1414,6 @@ func Test_verbose_option()
" clean up
call StopVimInTerminal(buf)
- call delete('XTest_verbose')
endfunc
func Test_setcmdpos()
@@ -1533,7 +1516,7 @@ func Test_cmdlineclear_tabenter()
call setline(1, range(30))
[SCRIPT]
- call writefile(lines, 'XtestCmdlineClearTabenter')
+ call writefile(lines, 'XtestCmdlineClearTabenter', 'D')
let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10})
call TermWait(buf, 25)
" in one tab make the command line higher with CTRL-W -
@@ -1541,7 +1524,6 @@ func Test_cmdlineclear_tabenter()
call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {})
call StopVimInTerminal(buf)
- call delete('XtestCmdlineClearTabenter')
endfunc
" Test for expanding special keywords in cmdline
@@ -1552,14 +1534,12 @@ func Test_cmdline_expand_special()
call assert_fails('e <abuf>', 'E496:')
call assert_fails('e <amatch>', 'E497:')
- call writefile([], 'Xfile.cpp')
- call writefile([], 'Xfile.java')
+ call writefile([], 'Xfile.cpp', 'D')
+ call writefile([], 'Xfile.java', 'D')
new Xfile.cpp
call feedkeys(":e %:r\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.cpp Xfile.java', @:)
close
- call delete('Xfile.cpp')
- call delete('Xfile.java')
endfunc
" Test for backtick expression in the command line
@@ -1593,11 +1573,10 @@ func Test_cmd_bang()
call delete('Xfile.out')
qall!
[SCRIPT]
- call writefile(lines, 'Xscript')
+ call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult'))
endif
- call delete('Xscript')
call delete('Xresult')
endfunc
@@ -1619,7 +1598,7 @@ endfunc
" Test for using ~ for home directory in cmdline completion matches
func Test_cmdline_expand_home()
- call mkdir('Xexpdir')
+ call mkdir('Xexpdir', 'R')
call writefile([], 'Xexpdir/Xfile1')
call writefile([], 'Xexpdir/Xfile2')
cd Xexpdir
@@ -1629,7 +1608,6 @@ func Test_cmdline_expand_home()
call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
let $HOME = save_HOME
cd ..
- call delete('Xexpdir', 'rf')
endfunc
" Test for using CTRL-\ CTRL-G in the command line to go back to normal mode
@@ -1714,8 +1692,8 @@ func Wildmode_tests()
" Test for longest file name completion with 'fileignorecase'
" On MS-Windows, file names are case insensitive.
if has('unix')
- call writefile([], 'XTESTfoo')
- call writefile([], 'Xtestbar')
+ call writefile([], 'XTESTfoo', 'D')
+ call writefile([], 'Xtestbar', 'D')
set nofileignorecase
call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e XTESTfoo', @:)
@@ -1727,8 +1705,6 @@ func Wildmode_tests()
call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xtest', @:)
set fileignorecase&
- call delete('XTESTfoo')
- call delete('Xtestbar')
endif
%argdelete
@@ -1750,7 +1726,7 @@ func Test_wildmode()
endfunc
func Test_custom_complete_autoload()
- call mkdir('Xcustdir/autoload', 'p')
+ call mkdir('Xcustdir/autoload', 'pR')
let save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xcustdir'
let lines =<< trim END
@@ -1769,7 +1745,6 @@ func Test_custom_complete_autoload()
let &rtp = save_rtp
set wildmode& wildmenu&
delcommand MyCmd
- call delete('Xcustdir', 'rf')
endfunc
" Test for interrupting the command-line completion
@@ -1946,7 +1921,7 @@ endfunc
func Test_wildmenu_dirstack()
CheckUnix
%bw!
- call mkdir('Xwildmenu/dir2/dir3/dir4', 'p')
+ call mkdir('Xwildmenu/dir2/dir3/dir4', 'pR')
call writefile([], 'Xwildmenu/file1_1.txt')
call writefile([], 'Xwildmenu/file1_2.txt')
call writefile([], 'Xwildmenu/dir2/file2_1.txt')
@@ -1974,7 +1949,6 @@ func Test_wildmenu_dirstack()
call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:)
- call delete('Xwildmenu', 'rf')
set wildmenu&
endfunc
@@ -2054,9 +2028,9 @@ endfunc
" Test for the 'suffixes' option
func Test_suffixes_opt()
- call writefile([], 'Xsuffile')
- call writefile([], 'Xsuffile.c')
- call writefile([], 'Xsuffile.o')
+ call writefile([], 'Xsuffile', 'D')
+ call writefile([], 'Xsuffile.c', 'D')
+ call writefile([], 'Xsuffile.o', 'D')
set suffixes=
call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xsuffile Xsuffile.c Xsuffile.o', @:)
@@ -2076,9 +2050,6 @@ func Test_suffixes_opt()
" Test for getcompletion() with different patterns
call assert_equal(['Xsuffile', 'Xsuffile.c', 'Xsuffile.o'], getcompletion('Xsuffile', 'file'))
call assert_equal(['Xsuffile'], getcompletion('Xsuffile$', 'file'))
- call delete('Xsuffile')
- call delete('Xsuffile.c')
- call delete('Xsuffile.o')
endfunc
" Test for using a popup menu for the command line completion matches
@@ -2120,7 +2091,7 @@ func Test_wildmenu_pum()
call feedkeys(":edit $VIMRUNTIME/\<Tab>\<Left>\<C-U>ab\<Tab>")
endfunc
[CODE]
- call writefile(commands, 'Xtest')
+ call writefile(commands, 'Xtest', 'D')
let buf = RunVimInTerminal('-S Xtest', #{rows: 10})
@@ -2258,7 +2229,7 @@ func Test_wildmenu_pum()
call VerifyScreenDump(buf, 'Test_wildmenu_pum_31', {})
" Tests a directory name contained full-width characters.
- call mkdir('Xnamedir/あいう', 'p')
+ call mkdir('Xnamedir/あいう', 'pR')
call writefile([], 'Xnamedir/あいう/abc')
call writefile([], 'Xnamedir/あいう/xyz')
call writefile([], 'Xnamedir/あいう/123')
@@ -2346,8 +2317,6 @@ func Test_wildmenu_pum()
call term_sendkeys(buf, "\<C-U>\<CR>")
call StopVimInTerminal(buf)
- call delete('Xtest')
- call delete('Xnamedir', 'rf')
endfunc
" Test for wildmenumode() with the cmdline popup menu
@@ -2378,7 +2347,7 @@ func Test_wildmenu_with_pum_foldexpr()
set foldtext=MyFoldText() wildoptions=pum
normal ggzfj
END
- call writefile(lines, 'Xpumfold')
+ call writefile(lines, 'Xpumfold', 'D')
let buf = RunVimInTerminal('-S Xpumfold', #{rows: 10})
call term_sendkeys(buf, ":set\<Tab>")
call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_1', {})
@@ -2387,7 +2356,6 @@ func Test_wildmenu_with_pum_foldexpr()
call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_2', {})
call StopVimInTerminal(buf)
- call delete('Xpumfold')
endfunc
" Test for opening the cmdline completion popup menu from the terminal window.
@@ -2402,7 +2370,7 @@ func Test_wildmenu_pum_from_terminal()
let cmds = ['set wildmenu wildoptions=pum']
let pcmd = python .. ' -c "import sys; sys.stdout.write(sys.stdin.read())"'
call add(cmds, "call term_start('" .. pcmd .. "')")
- call writefile(cmds, 'Xtest')
+ call writefile(cmds, 'Xtest', 'D')
let buf = RunVimInTerminal('-S Xtest', #{rows: 10})
call term_sendkeys(buf, "\r\r\r")
call term_wait(buf)
@@ -2411,7 +2379,6 @@ func Test_wildmenu_pum_from_terminal()
call VerifyScreenDump(buf, 'Test_wildmenu_pum_term_01', {})
call term_wait(buf)
call StopVimInTerminal(buf)
- call delete('Xtest')
endfunc
" Test for completion after a :substitute command followed by a pipe (|)
@@ -2511,7 +2478,7 @@ endfunc
func Test_fuzzy_completion_bufname_fullpath()
CheckUnix
set wildoptions&
- call mkdir('Xcmd/Xstate/Xfile.js', 'p')
+ call mkdir('Xcmd/Xstate/Xfile.js', 'pR')
edit Xcmd/Xstate/Xfile.js
cd Xcmd/Xstate
enew
@@ -2521,7 +2488,6 @@ func Test_fuzzy_completion_bufname_fullpath()
call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_match('Xcmd/Xstate/Xfile.js$', @:)
cd -
- call delete('Xcmd', 'rf')
set wildoptions&
endfunc
@@ -3028,7 +2994,7 @@ func Test_cmdline_complete_breakadd()
call assert_equal([], l)
" Test for :breakadd file [lnum] <file>
- call writefile([], 'Xscript')
+ call writefile([], 'Xscript', 'D')
call feedkeys(":breakadd file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal("\"breakadd file Xscript", @:)
call feedkeys(":breakadd file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
@@ -3047,7 +3013,6 @@ func Test_cmdline_complete_breakadd()
call assert_equal("\"breakadd file Xscript ", @:)
call feedkeys(":breakadd file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal("\"breakadd file X1B2C3", @:)
- call delete('Xscript')
" Test for :breakadd func [lnum] <function>
func Xbreak_func()
@@ -3109,7 +3074,7 @@ func Test_cmdline_complete_breakdel()
call assert_equal("\"breakdel abc", @:)
" Test for :breakdel file [lnum] <file>
- call writefile([], 'Xscript')
+ call writefile([], 'Xscript', 'D')
call feedkeys(":breakdel file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal("\"breakdel file Xscript", @:)
call feedkeys(":breakdel file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
@@ -3128,7 +3093,6 @@ func Test_cmdline_complete_breakdel()
call assert_equal("\"breakdel file Xscript ", @:)
call feedkeys(":breakdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal("\"breakdel file X1B2C3", @:)
- call delete('Xscript')
" Test for :breakdel func [lnum] <function>
func Xbreak_func()
@@ -3165,7 +3129,7 @@ endfunc
" Test for :scriptnames argument completion
func Test_cmdline_complete_scriptnames()
set wildmenu
- call writefile(['let a = 1'], 'Xa1b2c3.vim')
+ call writefile(['let a = 1'], 'Xa1b2c3.vim', 'D')
source Xa1b2c3.vim
call feedkeys(":script \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx')
call assert_match("\"script .*Xa1b2c3.vim$", @:)
@@ -3185,7 +3149,6 @@ func Test_cmdline_complete_scriptnames()
call feedkeys(":script \<Tab>\<Left>\<Left>\<CR>", 'tx')
call assert_equal('Xa1b2c3.vim', fnamemodify(@%, ':t'))
bw!
- call delete('Xa1b2c3.vim')
set wildmenu&
endfunc
@@ -3259,13 +3222,12 @@ func Test_cmdline_redraw_tabline()
set showtabline=2
autocmd CmdlineEnter * set tabline=foo
END
- call writefile(lines, 'Xcmdline_redraw_tabline')
+ call writefile(lines, 'Xcmdline_redraw_tabline', 'D')
let buf = RunVimInTerminal('-S Xcmdline_redraw_tabline', #{rows: 6})
call term_sendkeys(buf, ':')
call WaitForAssert({-> assert_match('^foo', term_getline(buf, 1))})
call StopVimInTerminal(buf)
- call delete('Xcmdline_redraw_tabline')
endfunc
func Test_wildmenu_pum_disable_while_shown()