# HG changeset patch # User Bram Moolenaar # Date 1665868504 -7200 # Node ID bff3fa5f4c7422b8ba5cc76cdc621627a8d9d176 # Parent ae65ad930e86de89a4875384fb7b113ec176def2 patch 9.0.0769: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/db4c94788ad70118fa1ccc5fbc821757350ac771 Author: Bram Moolenaar Date: Sat Oct 15 22:06:06 2022 +0100 patch 9.0.0769: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible. diff --git a/src/testdir/test_winbar.vim b/src/testdir/test_winbar.vim --- a/src/testdir/test_winbar.vim +++ b/src/testdir/test_winbar.vim @@ -132,13 +132,12 @@ func Test_winbar_not_visible() wincmd j wincmd _ END - call writefile(lines, 'XtestWinbarNotVisble') + call writefile(lines, 'XtestWinbarNotVisble', 'D') let buf = RunVimInTerminal('-S XtestWinbarNotVisble', #{rows: 10}) call VerifyScreenDump(buf, 'Test_winbar_not_visible', {}) " clean up call StopVimInTerminal(buf) - call delete('XtestWinbarNotVisble') endfunction func Test_winbar_not_visible_custom_statusline() @@ -152,13 +151,12 @@ func Test_winbar_not_visible_custom_stat wincmd j wincmd _ END - call writefile(lines, 'XtestWinbarNotVisble') + call writefile(lines, 'XtestWinbarNotVisble', 'D') let buf = RunVimInTerminal('-S XtestWinbarNotVisble', #{rows: 10}) call VerifyScreenDump(buf, 'Test_winbar_not_visible_custom_statusline', {}) " clean up call StopVimInTerminal(buf) - call delete('XtestWinbarNotVisble') endfunction func Test_drag_statusline_with_winbar() diff --git a/src/testdir/test_winbuf_close.vim b/src/testdir/test_winbuf_close.vim --- a/src/testdir/test_winbuf_close.vim +++ b/src/testdir/test_winbuf_close.vim @@ -12,9 +12,9 @@ func Test_winbuf_close() enew | only - call writefile(['testtext 1'], 'Xtest1') - call writefile(['testtext 2'], 'Xtest2') - call writefile(['testtext 3'], 'Xtest3') + call writefile(['testtext 1'], 'Xtest1', 'D') + call writefile(['testtext 2'], 'Xtest2', 'D') + call writefile(['testtext 3'], 'Xtest3', 'D') next! Xtest1 Xtest2 call setline(1, 'testtext 1 1') @@ -117,10 +117,6 @@ func Test_winbuf_close() call assert_equal('Xtest3', bufname('%')) call assert_fails('silent! quit!', 'E37:') call assert_equal('Xtest1', bufname('%')) - - call delete('Xtest1') - call delete('Xtest2') - call delete('Xtest3') endfunc " Test that ":close" will respect 'winfixheight' when possible. diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -69,8 +69,8 @@ endfunc func Test_window_cmd_wincmd_gf() let fname = 'test_gf.txt' let swp_fname = '.' . fname . '.swp' - call writefile([], fname) - call writefile([], swp_fname) + call writefile([], fname, 'D') + call writefile([], swp_fname, 'D') function s:swap_exists() let v:swapchoice = s:swap_choice endfunc @@ -96,8 +96,6 @@ func Test_window_cmd_wincmd_gf() call assert_notequal(fname, bufname("%")) new | only! - call delete(fname) - call delete(swp_fname) augroup! test_window_cmd_wincmd_gf endfunc @@ -740,7 +738,7 @@ func Test_window_prevwin() CheckUnix set hidden autoread - call writefile(['2'], 'tmp.txt') + call writefile(['2'], 'tmp.txt', 'D') new tmp.txt q call Fun_RenewFile() @@ -756,7 +754,6 @@ func Test_window_prevwin() wincmd p " reset q - call delete('tmp.txt') set hidden&vim autoread&vim delfunc Fun_RenewFile endfunc @@ -1082,9 +1079,9 @@ func Run_noroom_for_newwindow_test(dir_a endtry endwhile - call writefile(['first', 'second', 'third'], 'Xnorfile1') - call writefile([], 'Xnorfile2') - call writefile([], 'Xnorfile3') + call writefile(['first', 'second', 'third'], 'Xnorfile1', 'D') + call writefile([], 'Xnorfile2', 'D') + call writefile([], 'Xnorfile3', 'D') " Argument list related commands args Xnorfile1 Xnorfile2 Xnorfile3 @@ -1165,9 +1162,6 @@ func Run_noroom_for_newwindow_test(dir_a endif %bwipe! - call delete('Xnorfile1') - call delete('Xnorfile2') - call delete('Xnorfile3') only endfunc diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -5,8 +5,8 @@ source term_util.vim func Test_writefile() let f = tempname() - call writefile(["over","written"], f, "b") - call writefile(["hello","world"], f, "b") + call writefile(["over", "written"], f, "bD") + call writefile(["hello", "world"], f, "b") call writefile(["!", "good"], f, "a") call writefile(["morning"], f, "ab") call writefile(["", "vimmers"], f, "ab") @@ -16,7 +16,6 @@ func Test_writefile() call assert_equal("good", l[2]) call assert_equal("morning", l[3]) call assert_equal("vimmers", l[4]) - call delete(f) call assert_fails('call writefile("text", "Xwffile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob') endfunc @@ -52,7 +51,7 @@ func Test_writefile_fails_conversion() set nobackup nowritebackup backupdir=. backupskip= new let contents = ["line one", "line two"] - call writefile(contents, 'Xwfcfile') + call writefile(contents, 'Xwfcfile', 'D') edit Xwfcfile call setline(1, ["first line", "cannot convert \u010b", "third line"]) call assert_fails('write ++enc=cp932', 'E513:') @@ -79,7 +78,6 @@ func Test_writefile_fails_conversion() call delete('Xwfcfily~') %bw! - call delete('Xwfcfile') call delete('Xwfcfile' .. &backupext) bwipe! set backup& writebackup& backupdir&vim backupskip&vim @@ -94,7 +92,7 @@ func Test_writefile_fails_conversion2() " but then the backup file must remain set nobackup writebackup backupdir=. backupskip= let contents = ["line one", "line two"] - call writefile(contents, 'Xwf2file_conversion_err') + call writefile(contents, 'Xwf2file_conversion_err', 'D') edit Xwf2file_conversion_err call setline(1, ["first line", "cannot convert \u010b", "third line"]) set fileencoding=latin1 @@ -102,7 +100,6 @@ func Test_writefile_fails_conversion2() call assert_match('CONVERSION ERROR', output) call assert_equal(contents, readfile('Xwf2file_conversion_err~')) - call delete('Xwf2file_conversion_err') call delete('Xwf2file_conversion_err~') bwipe! set backup& writebackup& backupdir&vim backupskip&vim @@ -154,9 +151,8 @@ endfunc func Test_writefile_sync_arg() " This doesn't check if fsync() works, only that the argument is accepted. - call writefile(['one'], 'Xtest', 's') + call writefile(['one'], 'Xtest', 'sD') call writefile(['two'], 'Xtest', 'S') - call delete('Xtest') endfunc func Test_writefile_sync_dev_stdout() @@ -311,7 +307,7 @@ func Test_write_file_mtime() CheckRunVimInTerminal " First read the file into a buffer - call writefile(["Line1", "Line2"], 'Xwfmfile') + call writefile(["Line1", "Line2"], 'Xwfmfile', 'D') let old_ftime = getftime('Xwfmfile') let buf = RunVimInTerminal('Xwfmfile', #{rows : 10}) call TermWait(buf) @@ -347,7 +343,6 @@ func Test_write_file_mtime() " clean up call StopVimInTerminal(buf) - call delete('Xwfmfile') endfunc " Test for an autocmd unloading a buffer during a write command @@ -417,7 +412,7 @@ endfunc " Test for writing to a readonly file func Test_write_readonly() - call writefile([], 'Xwrofile') + call writefile([], 'Xwrofile', 'D') call setfperm('Xwrofile', "r--------") edit Xwrofile set noreadonly backupskip= @@ -442,13 +437,12 @@ func Test_write_readonly() set autowriteall& set backupskip& - call delete('Xwrofile') %bw! endfunc " Test for 'patchmode' func Test_patchmode() - call writefile(['one'], 'Xpafile') + call writefile(['one'], 'Xpafile', 'D') set patchmode=.orig nobackup backupskip= writebackup new Xpafile call setline(1, 'two') @@ -473,7 +467,6 @@ func Test_patchmode() call assert_equal([], readfile('Xpafile.orig')) set patchmode& backup& backupskip& writebackup& - call delete('Xpafile') call delete('Xpafile.orig') endfunc @@ -485,7 +478,7 @@ func Test_write_readonly_dir() " Root can do it too. CheckNotRoot - call mkdir('Xrodir/') + call mkdir('Xrodir/', 'R') call writefile(['one'], 'Xrodir/Xfile1') call setfperm('Xrodir', 'r-xr--r--') " try to create a new file in the directory @@ -498,7 +491,6 @@ func Test_write_readonly_dir() set patchmode=.orig call assert_fails('write', 'E509:') call setfperm('Xrodir', 'rwxr--r--') - call delete('Xrodir', 'rf') set backupdir& backupskip& patchmode& endfunc @@ -521,7 +513,7 @@ func Test_write_file_encoding() 2 cp1251 text: ─ы  Vim version 6.2. ╧юёыхфэхх шчьхэхэшх: 1970 Jan 01 3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 END - call writefile(text, 'Xwfefile') + call writefile(text, 'Xwfefile', 'D') edit Xwfefile " write tests: @@ -614,7 +606,6 @@ func Test_write_file_encoding() END call assert_equal(expected, readfile('Xwfetest')) - call delete('Xwfefile') call delete('Xwfetest') call delete('Xutf8') call delete('Xcp1251') @@ -641,7 +632,7 @@ func Test_readwrite_file_with_bom() set cpoptions+=S " Check that editing a latin1 file doesn't see a BOM - call writefile(["\xFE\xFElatin-1"], 'Xrwtest1') + call writefile(["\xFE\xFElatin-1"], 'Xrwtest1', 'D') edit Xrwtest1 call assert_equal('latin1', &fileencoding) call assert_equal(0, &bomb) @@ -746,7 +737,6 @@ func Test_readwrite_file_with_bom() set cpoptions-=S let &fileencoding = save_fileencoding - call delete('Xrwtest1') call delete('Xrwfile2') call delete('Xrwtest3') %bw! @@ -754,7 +744,7 @@ endfunc func Test_read_write_bin() " write file missing EOL - call writefile(['noeol'], "XNoEolSetEol", 'bS') + call writefile(['noeol'], "XNoEolSetEol", 'bSD') call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B')) " when file is read 'eol' is off @@ -767,7 +757,6 @@ func Test_read_write_bin() w call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B')) - call delete('XNoEolSetEol') set ff& fixeol& bwipe! XNoEolSetEol endfunc @@ -899,7 +888,7 @@ func Test_write_backup_symlink() call mkdir('Xbackup') let save_backupdir = &backupdir set backupdir=.,./Xbackup - call writefile(['1111'], 'Xwbsfile') + call writefile(['1111'], 'Xwbsfile', 'D') silent !ln -s Xwbsfile Xwbsfile.bak new Xwbsfile @@ -915,7 +904,6 @@ func Test_write_backup_symlink() set backup& backupcopy& backupext& %bw - call delete('Xwbsfile') call delete('Xwbsfile.bak') call delete('Xbackup', 'rf') let &backupdir = save_backupdir @@ -924,7 +912,7 @@ endfunc " Test for ':write ++bin' and ':write ++nobin' func Test_write_binary_file() " create a file without an eol/eof character - call writefile(0z616161, 'Xwbfile1', 'b') + call writefile(0z616161, 'Xwbfile1', 'bD') new Xwbfile1 write ++bin Xwbfile2 write ++nobin Xwbfile3 @@ -934,7 +922,6 @@ func Test_write_binary_file() else call assert_equal(0z6161610A, readblob('Xwbfile3')) endif - call delete('Xwbfile1') call delete('Xwbfile2') call delete('Xwbfile3') endfunc diff --git a/src/testdir/test_xxd.vim b/src/testdir/test_xxd.vim --- a/src/testdir/test_xxd.vim +++ b/src/testdir/test_xxd.vim @@ -274,8 +274,8 @@ endfunc func Test_xxd_patch() let cmd1 = 'silent !' .. s:xxd_cmd .. ' -r Xxxdin Xxxdfile' let cmd2 = 'silent !' .. s:xxd_cmd .. ' -g1 Xxxdfile > Xxxdout' - call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin') - call writefile(['::::::::'], 'Xxxdfile') + call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin', 'D') + call writefile(['::::::::'], 'Xxxdfile', 'D') exe cmd1 exe cmd2 call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42 ::AA::::BB'], readfile('Xxxdout')) @@ -306,8 +306,6 @@ func Test_xxd_patch() exe cmd2 call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 42 44 46 46 ::EE::::BDFF'], readfile('Xxxdout')) - call delete('Xxxdin') - call delete('Xxxdfile') call delete('Xxxdout') endfunc @@ -369,7 +367,7 @@ endfunc " -c0 selects the format specific default column value, as if no -c was given " except for -ps, where it disables extra newlines func Test_xxd_c0_is_def_cols() - call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin') + call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin', 'D') for cols in ['-c0', '-c 0', '-cols 0'] for fmt in ['', '-b', '-e', '-i'] exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1' @@ -377,7 +375,6 @@ func Test_xxd_c0_is_def_cols() call assert_equalfile('Xxdout1', 'Xxdout2') endfor endfor - call delete('Xxdin') call delete('Xxdout1') call delete('Xxdout2') endfunc @@ -391,7 +388,7 @@ func Test_xxd_plain_one_line() \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"], - \ 'Xxdin') + \ 'Xxdin', 'D') for cols in ['-c0', '-c 0', '-cols 0'] exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin' " output seems to start in line 2 @@ -402,7 +399,6 @@ func Test_xxd_plain_one_line() " xxd output must be non-empty and comprise only lower case hex digits call assert_match("^[0-9a-f][0-9a-f]*$", out) endfor - call delete('Xxdin') endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 769, +/**/ 768, /**/ 767,