To: vim_dev@googlegroups.com Subject: Patch 9.0.0669 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0669 Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible. Files: src/testdir/test_quickfix.vim, src/testdir/test_recover.vim, src/testdir/test_regexp_utf8.vim, src/testdir/test_rename.vim, src/testdir/test_restricted.vim *** ../vim-9.0.0668/src/testdir/test_quickfix.vim 2022-08-29 22:31:15.919685279 +0100 --- src/testdir/test_quickfix.vim 2022-10-05 21:31:38.186892171 +0100 *************** *** 396,402 **** Xtestfile1:700:10:Line 700 Xtestfile2:800:15:Line 800 END ! call writefile(lines, 'Xqftestfile1') enew! Xfile Xqftestfile1 --- 396,402 ---- Xtestfile1:700:10:Line 700 Xtestfile2:800:15:Line 800 END ! call writefile(lines, 'Xqftestfile1', 'D') enew! Xfile Xqftestfile1 *************** *** 439,446 **** call writefile([t], 'Xqftestfile1', 'b') silent! Xfile Xqftestfile1 call assert_equal(text, g:Xgetlist()[0].text) - - call delete('Xqftestfile1') endfunc func Test_cfile() --- 439,444 ---- *************** *** 795,804 **** call assert_fails('Xbuffer', 'E342:') %bw! ! call writefile([repeat('a', 8192)], 'Xtest') call test_alloc_fail(GetAllocId('qf_linebuf'), 0, 0) call assert_fails('Xfile Xtest', 'E342:') - call delete('Xtest') endfunc func Test_nomem() --- 793,801 ---- call assert_fails('Xbuffer', 'E342:') %bw! ! call writefile([repeat('a', 8192)], 'Xtest', 'D') call test_alloc_fail(GetAllocId('qf_linebuf'), 0, 0) call assert_fails('Xfile Xtest', 'E342:') endfunc func Test_nomem() *************** *** 899,905 **** var rtp_save = &rtp var dir = 'Xruntime/after' &rtp ..= ',' .. dir ! mkdir(dir .. '/ftplugin', 'p') writefile(['vim9script'], dir .. '/ftplugin/qf.vim') filetype plugin on silent helpgrep grail --- 896,902 ---- var rtp_save = &rtp var dir = 'Xruntime/after' &rtp ..= ',' .. dir ! mkdir(dir .. '/ftplugin', 'pR') writefile(['vim9script'], dir .. '/ftplugin/qf.vim') filetype plugin on silent helpgrep grail *************** *** 907,913 **** silent helpgrep grail assert_equal('aABceFs', &cpo) - delete('Xruntime', 'rf') &rtp = rtp_save cclose helpclose --- 904,909 ---- *************** *** 1180,1187 **** endfunc func Test_locationlist_cross_tab_jump() ! call writefile(['loclistfoo'], 'loclistfoo') ! call writefile(['loclistbar'], 'loclistbar') set switchbuf=usetab edit loclistfoo --- 1176,1183 ---- endfunc func Test_locationlist_cross_tab_jump() ! call writefile(['loclistfoo'], 'loclistfoo', 'D') ! call writefile(['loclistbar'], 'loclistbar', 'D') set switchbuf=usetab edit loclistfoo *************** *** 1191,1198 **** enew | only | tabonly set switchbuf&vim - call delete('loclistfoo') - call delete('loclistbar') endfunc " More tests for 'errorformat' --- 1187,1192 ---- *************** *** 1237,1244 **** "Xtestfile", line 22 col 9: What is the title of the quickfix window? [DATA] ! call writefile(l, 'Xerrorfile1') ! call writefile(l[:-2], 'Xerrorfile2') let m =<< [DATA] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2 --- 1231,1239 ---- "Xtestfile", line 22 col 9: What is the title of the quickfix window? [DATA] ! call writefile(l, 'Xerrorfile1', 'D') ! call delete('loclistbar') ! call writefile(l[:-2], 'Xerrorfile2', 'D') let m =<< [DATA] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2 *************** *** 1263,1269 **** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22 [DATA] ! call writefile(m, 'Xtestfile') let save_efm = &efm set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m --- 1258,1264 ---- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22 [DATA] ! call writefile(m, 'Xtestfile', 'D') let save_efm = &efm set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m *************** *** 1309,1317 **** wincmd p let &efm = save_efm - call delete('Xerrorfile1') - call delete('Xerrorfile2') - call delete('Xtestfile') endfunc " Test for quickfix directory stack support --- 1304,1309 ---- *************** *** 1363,1373 **** " Tests for %D and %X errorformat options func Test_efm_dirstack() " Create the directory stack and files ! call mkdir('dir1') call mkdir('dir1/a') call mkdir('dir1/a/b') call mkdir('dir1/c') ! call mkdir('dir2') let lines =<< trim END Nine Healthy Habits --- 1355,1365 ---- " Tests for %D and %X errorformat options func Test_efm_dirstack() " Create the directory stack and files ! call mkdir('dir1', 'R') call mkdir('dir1/a') call mkdir('dir1/a/b') call mkdir('dir1/c') ! call mkdir('dir2', 'R') let lines =<< trim END Nine Healthy Habits *************** *** 1382,1388 **** 8 Hours of sleep (at least) 9 PM end of the day and off to bed END ! call writefile(lines, 'habits1.txt') call writefile(lines, 'dir1/a/habits2.txt') call writefile(lines, 'dir1/a/b/habits3.txt') call writefile(lines, 'dir1/c/habits4.txt') --- 1374,1380 ---- 8 Hours of sleep (at least) 9 PM end of the day and off to bed END ! call writefile(lines, 'habits1.txt', 'D') call writefile(lines, 'dir1/a/habits2.txt') call writefile(lines, 'dir1/a/b/habits3.txt') call writefile(lines, 'dir1/c/habits4.txt') *************** *** 1390,1399 **** call s:dir_stack_tests('c') call s:dir_stack_tests('l') - - call delete('dir1', 'rf') - call delete('dir2', 'rf') - call delete('habits1.txt') endfunc " Test for resync after continuing an ignored message --- 1382,1387 ---- *************** *** 1518,1526 **** set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r " To exercise the push/pop file functionality in quickfix, the test files " need to be created. ! call writefile(['Line1'], 'Xtestfile1') ! call writefile(['Line2'], 'Xtestfile2') ! call writefile(['Line3'], 'Xtestfile3') cexpr "" for l in lines caddexpr l --- 1506,1514 ---- set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r " To exercise the push/pop file functionality in quickfix, the test files " need to be created. ! call writefile(['Line1'], 'Xtestfile1', 'D') ! call writefile(['Line2'], 'Xtestfile2', 'D') ! call writefile(['Line3'], 'Xtestfile3', 'D') cexpr "" for l in lines caddexpr l *************** *** 1531,1539 **** call assert_equal(2, l[2].col) call assert_equal('w', l[2].type) call assert_equal('e', l[3].type) - call delete('Xtestfile1') - call delete('Xtestfile2') - call delete('Xtestfile3') " Test for %P, %Q with non-existing files cexpr lines --- 1519,1524 ---- *************** *** 1602,1608 **** " Test for %o set efm=%f(%o):%l\ %m cgetexpr ['Xotestfile(Language.PureScript.Types):20 Error'] ! call writefile(['Line1'], 'Xotestfile') let l = getqflist() call assert_equal(1, len(l), string(l)) call assert_equal('Language.PureScript.Types', l[0].module) --- 1587,1593 ---- " Test for %o set efm=%f(%o):%l\ %m cgetexpr ['Xotestfile(Language.PureScript.Types):20 Error'] ! call writefile(['Line1'], 'Xotestfile', 'D') let l = getqflist() call assert_equal(1, len(l), string(l)) call assert_equal('Language.PureScript.Types', l[0].module) *************** *** 1612,1618 **** call assert_equal('Xotestfile', expand('%:t')) cclose bd - call delete("Xotestfile") " Test for a long module name cexpr 'Xtest(' . repeat('m', 1026) . '):15 message' --- 1597,1602 ---- *************** *** 1776,1782 **** endfunc func Test_setloclist_in_autocommand() ! call writefile(['test1', 'test2'], 'Xfile') edit Xfile let s:bufnr = bufnr() call setloclist(1, --- 1760,1766 ---- endfunc func Test_setloclist_in_autocommand() ! call writefile(['test1', 'test2'], 'Xfile', 'D') edit Xfile let s:bufnr = bufnr() call setloclist(1, *************** *** 1796,1802 **** augroup Test_LocList au! augroup END - call delete('Xfile') endfunc func Test_caddbuffer_to_empty() --- 1780,1785 ---- *************** *** 2129,2139 **** /tmp/file4:1:1:ccc END let lines[1] = substitute(lines[1], '%s', repeat('x', len), '') ! call writefile(lines, 'Xcqetfile.txt') cgetfile Xcqetfile.txt call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len) endfor - call delete('Xcqetfile.txt') endfunc func s:create_test_file(filename) --- 2112,2121 ---- /tmp/file4:1:1:ccc END let lines[1] = substitute(lines[1], '%s', repeat('x', len), '') ! call writefile(lines, 'Xcqetfile.txt', 'D') cgetfile Xcqetfile.txt call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len) endfor endfunc func s:create_test_file(filename) *************** *** 2274,2280 **** " If opening a file changes 'switchbuf', then the new value should be " retained. set modeline&vim ! call writefile(["vim: switchbuf=split"], 'Xqftestfile1') enew | only set switchbuf&vim cexpr "Xqftestfile1:1:10" --- 2256,2262 ---- " If opening a file changes 'switchbuf', then the new value should be " retained. set modeline&vim ! call writefile(["vim: switchbuf=split"], 'Xqftestfile1', 'D') enew | only set switchbuf&vim cexpr "Xqftestfile1:1:10" *************** *** 2290,2296 **** cexpr "Xqftestfile1:1:10" call assert_equal('', &switchbuf) - call delete('Xqftestfile1') call delete('Xqftestfile2') call delete('Xqftestfile3') set switchbuf&vim --- 2272,2277 ---- *************** *** 2385,2392 **** " Use one 'errorformat' for two windows. Add an expression to each of them, " make sure they each keep their own state. set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' ! call mkdir('Xone/a', 'p') ! call mkdir('Xtwo/a', 'p') let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] call writefile(lines, 'Xone/a/one.txt') call writefile(lines, 'Xtwo/a/two.txt') --- 2366,2373 ---- " Use one 'errorformat' for two windows. Add an expression to each of them, " make sure they each keep their own state. set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' ! call mkdir('Xone/a', 'pR') ! call mkdir('Xtwo/a', 'pR') let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] call writefile(lines, 'Xone/a/one.txt') call writefile(lines, 'Xtwo/a/two.txt') *************** *** 2418,2425 **** bwipe! call win_gotoid(two_id) bwipe! - call delete('Xone', 'rf') - call delete('Xtwo', 'rf') endfunc func XbottomTests(cchar) --- 2399,2404 ---- *************** *** 2503,2514 **** let last_buffer = bufnr("$") " make sure only one buffer is created ! call writefile(['this one', 'that one'], 'Xgrepthis') vimgrep one Xgrepthis vimgrep one Xgrepthis call assert_equal(last_buffer + 1, bufnr("$")) - - call delete('Xgrepthis') endfunc " Quickfix/Location list set/get properties tests --- 2482,2491 ---- let last_buffer = bufnr("$") " make sure only one buffer is created ! call writefile(['this one', 'that one'], 'Xgrepthis', 'D') vimgrep one Xgrepthis vimgrep one Xgrepthis call assert_equal(last_buffer + 1, bufnr("$")) endfunc " Quickfix/Location list set/get properties tests *************** *** 2876,2883 **** END call assert_equal(l, g:acmds) ! call writefile(['Xtest:1:Line1'], 'Xtest') ! call writefile([], 'Xempty') let g:acmds = [] cfile Xtest caddfile Xtest --- 2853,2860 ---- END call assert_equal(l, g:acmds) ! call writefile(['Xtest:1:Line1'], 'Xtest', 'D') ! call writefile([], 'Xempty', 'D') let g:acmds = [] cfile Xtest caddfile Xtest *************** *** 2976,2983 **** call assert_equal(l, g:acmds) endif - call delete('Xtest') - call delete('Xempty') au! QuickFixCmdPre au! QuickFixCmdPost endfunc --- 2953,2958 ---- *************** *** 3137,3143 **** redraw cwindow 4 END ! call writefile(lines, 'XtestCwindow') let buf = RunVimInTerminal('-S XtestCwindow', #{rows: 12}) call VerifyScreenDump(buf, 'Test_quickfix_cwindow_1', {}) --- 3112,3118 ---- redraw cwindow 4 END ! call writefile(lines, 'XtestCwindow', 'D') let buf = RunVimInTerminal('-S XtestCwindow', #{rows: 12}) call VerifyScreenDump(buf, 'Test_quickfix_cwindow_1', {}) *************** *** 3152,3158 **** " clean up call StopVimInTerminal(buf) - call delete('XtestCwindow') call delete('XCwindow') endfunc --- 3127,3132 ---- *************** *** 3164,3171 **** Editor:Emacs EmAcS Editor:Notepad NOTEPAD END ! call writefile(lines, 'Xtestfile1') ! call writefile(['Linux', 'macOS', 'MS-Windows'], 'Xtestfile2') " Error cases call assert_fails('Xvimgrep /abc *', 'E682:') --- 3138,3145 ---- Editor:Emacs EmAcS Editor:Notepad NOTEPAD END ! call writefile(lines, 'Xtestfile1', 'D') ! call writefile(['Linux', 'macOS', 'MS-Windows'], 'Xtestfile2', 'D') " Error cases call assert_fails('Xvimgrep /abc *', 'E682:') *************** *** 3221,3229 **** augroup QF_Test au! augroup END - - call delete('Xtestfile1') - call delete('Xtestfile2') endfunc " Tests for the :vimgrep command --- 3195,3200 ---- *************** *** 3261,3271 **** call writefile(v:errors, 'Xresult') qall! [SCRIPT] ! call writefile(lines, 'Xscript') if RunVim([], [], '--clean -S Xscript') call assert_equal([], readfile('Xresult')) endif - call delete('Xscript') call delete('Xresult') endfunc --- 3232,3241 ---- call writefile(v:errors, 'Xresult') qall! [SCRIPT] ! call writefile(lines, 'Xscript', 'D') if RunVim([], [], '--clean -S Xscript') call assert_equal([], readfile('Xresult')) endif call delete('Xresult') endfunc *************** *** 3276,3292 **** call writefile(['done'], 'Xresult') qall! [SCRIPT] ! call writefile(lines, 'Xscript') if RunVim([], [], '--clean -n -S Xscript Xscript') call assert_equal(['done'], readfile('Xresult')) endif - call delete('Xscript') call delete('Xresult') endfunc func Test_vimgrep_existing_swapfile() ! call writefile(['match apple with apple'], 'Xapple') ! call writefile(['swapfile'], '.Xapple.swp') let g:foundSwap = 0 let g:ignoreSwapExists = 1 augroup grep --- 3246,3261 ---- call writefile(['done'], 'Xresult') qall! [SCRIPT] ! call writefile(lines, 'Xscript', 'D') if RunVim([], [], '--clean -n -S Xscript Xscript') call assert_equal(['done'], readfile('Xresult')) endif call delete('Xresult') endfunc func Test_vimgrep_existing_swapfile() ! call writefile(['match apple with apple'], 'Xapple', 'D') ! call writefile(['swapfile'], '.Xapple.swp', 'D') let g:foundSwap = 0 let g:ignoreSwapExists = 1 augroup grep *************** *** 3296,3303 **** call assert_equal(1, g:foundSwap) call assert_match('.Xapple.swo', swapname('')) - call delete('Xapple') - call delete('.Xapple.swp') augroup grep au! SwapExists augroup END --- 3265,3270 ---- *************** *** 3638,3645 **** endfunc func Test_multidirstack() ! call mkdir('Xone/a', 'p') ! call mkdir('Xtwo/a', 'p') let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] call writefile(lines, 'Xone/a/one.txt') call writefile(lines, 'Xtwo/a/two.txt') --- 3605,3612 ---- endfunc func Test_multidirstack() ! call mkdir('Xone/a', 'pR') ! call mkdir('Xtwo/a', 'pR') let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] call writefile(lines, 'Xone/a/one.txt') call writefile(lines, 'Xtwo/a/two.txt') *************** *** 3650,3657 **** call Xmultidirstack_tests('l') let &efm = save_efm - call delete('Xone', 'rf') - call delete('Xtwo', 'rf') endfunc " Tests for per quickfix/location list file stack --- 3617,3622 ---- *************** *** 3700,3707 **** func Test_multifilestack() let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] ! call writefile(lines, 'one.txt') ! call writefile(lines, 'two.txt') let save_efm = &efm set efm=%+P[%f],(%l\\,%c)\ %m,%-Q --- 3665,3672 ---- func Test_multifilestack() let lines = ['1', '2', 'one one one', '4', 'two two two', '6', '7'] ! call writefile(lines, 'one.txt', 'D') ! call writefile(lines, 'two.txt', 'D') let save_efm = &efm set efm=%+P[%f],(%l\\,%c)\ %m,%-Q *************** *** 3709,3722 **** call Xmultifilestack_tests('l') let &efm = save_efm - call delete('one.txt') - call delete('two.txt') endfunc " Tests for per buffer 'efm' setting func Test_perbuf_efm() ! call writefile(["File1-10-Line10"], 'one.txt') ! call writefile(["File2#20#Line20"], 'two.txt') set efm=%f#%l#%m new | only new --- 3674,3685 ---- call Xmultifilestack_tests('l') let &efm = save_efm endfunc " Tests for per buffer 'efm' setting func Test_perbuf_efm() ! call writefile(["File1-10-Line10"], 'one.txt', 'D') ! call writefile(["File2#20#Line20"], 'two.txt', 'D') set efm=%f#%l#%m new | only new *************** *** 3731,3738 **** set efm& new | only - call delete('one.txt') - call delete('two.txt') endfunc " Open multiple help windows using ":lhelpgrep --- 3694,3699 ---- *************** *** 3908,3916 **** func Xqfjump_tests(cchar) call s:setup_commands(a:cchar) ! call writefile(["Line1\tFoo", "Line2"], 'F1') ! call writefile(["Line1\tBar", "Line2"], 'F2') ! call writefile(["Line1\tBaz", "Line2"], 'F3') call g:Xsetlist([], 'f') --- 3869,3877 ---- func Xqfjump_tests(cchar) call s:setup_commands(a:cchar) ! call writefile(["Line1\tFoo", "Line2"], 'F1', 'D') ! call writefile(["Line1\tBar", "Line2"], 'F2', 'D') ! call writefile(["Line1\tBaz", "Line2"], 'F3', 'D') call g:Xsetlist([], 'f') *************** *** 3999,4008 **** " Cleanup enew! new | only - - call delete('F1') - call delete('F2') - call delete('F3') endfunc func Test_qfjump() --- 3960,3965 ---- *************** *** 4118,4126 **** let &quickfixtextfunc = 's:Func' cgetfile [ex END ! call writefile(lines, 'Xquickfixtextfunc') call RunVim([], [], '-e -s -S Xquickfixtextfunc -c qa') - call delete('Xquickfixtextfunc') endfunc func Test_getqflist() --- 4075,4082 ---- let &quickfixtextfunc = 's:Func' cgetfile [ex END ! call writefile(lines, 'Xquickfixtextfunc', 'D') call RunVim([], [], '-e -s -S Xquickfixtextfunc -c qa') endfunc func Test_getqflist() *************** *** 4173,4179 **** \ {'filename' : 'F7', 'lnum' : 11, 'text' : 'L11'}], 'r') call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick) ! call writefile(["F8:80:L80", "F8:81:L81"], "Xone") Xfile Xone call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick) Xaddfile Xone --- 4129,4135 ---- \ {'filename' : 'F7', 'lnum' : 11, 'text' : 'L11'}], 'r') call assert_equal(2, g:Xgetlist({'changedtick' : 0}).changedtick) ! call writefile(["F8:80:L80", "F8:81:L81"], "Xone", 'D') Xfile Xone call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick) Xaddfile Xone *************** *** 4186,4193 **** call g:Xsetlist([], 'a', {'nr' : 1, "lines" : ["F10:10:L10"]}) call assert_equal(1, g:Xgetlist({'changedtick' : 0}).changedtick) call assert_equal(2, g:Xgetlist({'nr' : 1, 'changedtick' : 0}).changedtick) - - call delete("Xone") endfunc func Test_qf_tick() --- 4142,4147 ---- *************** *** 4341,4348 **** " :vimgrep/:lvimgrep commands are running. func Test_vimgrep_autocmd() call setqflist([], 'f') ! call writefile(['stars'], 'Xtest1.txt') ! call writefile(['stars'], 'Xtest2.txt') " Test 1: " When searching for a pattern using :vimgrep, if the quickfix list is --- 4295,4302 ---- " :vimgrep/:lvimgrep commands are running. func Test_vimgrep_autocmd() call setqflist([], 'f') ! call writefile(['stars'], 'Xtest1.txt', 'D') ! call writefile(['stars'], 'Xtest2.txt', 'D') " Test 1: " When searching for a pattern using :vimgrep, if the quickfix list is *************** *** 4373,4380 **** call assert_fails('lvimgrep stars Xtest*.txt', 'E926:') au! BufRead Xtest2.txt - call delete('Xtest1.txt') - call delete('Xtest2.txt') call setqflist([], 'f') endfunc --- 4327,4332 ---- *************** *** 4403,4416 **** endfunc func Test_vimgrep_autocmd_cd() ! call mkdir('Xgrepdir/a', 'p') ! call mkdir('Xgrepdir/b', 'p') call writefile(['a_L1_vim', 'a_L2_vim'], 'Xgrepdir/a/f1.txt') call writefile(['b_L1_vim', 'b_L2_vim'], 'Xgrepdir/b/f2.txt') call Xvimgrep_autocmd_cd('c') call Xvimgrep_autocmd_cd('l') %bwipe - call delete('Xgrepdir', 'rf') endfunc " The following test used to crash Vim --- 4355,4367 ---- endfunc func Test_vimgrep_autocmd_cd() ! call mkdir('Xgrepdir/a', 'pR') ! call mkdir('Xgrepdir/b', 'pR') call writefile(['a_L1_vim', 'a_L2_vim'], 'Xgrepdir/a/f1.txt') call writefile(['b_L1_vim', 'b_L2_vim'], 'Xgrepdir/b/f2.txt') call Xvimgrep_autocmd_cd('c') call Xvimgrep_autocmd_cd('l') %bwipe endfunc " The following test used to crash Vim *************** *** 4539,4545 **** " Otherwise due to indentation, the title is set with spaces at the beginning " of the command. func Test_qftitle() ! call writefile(["F1:1:Line1"], 'Xerr') " :cexpr exe "cexpr readfile('Xerr')" --- 4490,4496 ---- " Otherwise due to indentation, the title is set with spaces at the beginning " of the command. func Test_qftitle() ! call writefile(["F1:1:Line1"], 'Xerr', 'D') " :cexpr exe "cexpr readfile('Xerr')" *************** *** 4617,4623 **** call assert_equal(':setqflist()', getqflist({'title' : 1}).title) close - call delete('Xerr') call setqflist([], ' ', {'title' : 'Errors'}) copen --- 4568,4573 ---- *************** *** 4700,4706 **** " Test for cfile/lfile enew ! call writefile(l, 'Xerr') Xfile Xerr call assert_equal('Xtestfile1', @%) call assert_equal(2, line('.')) --- 4650,4656 ---- " Test for cfile/lfile enew ! call writefile(l, 'Xerr', 'D') Xfile Xerr call assert_equal('Xtestfile1', @%) call assert_equal(2, line('.')) *************** *** 4711,4717 **** call assert_equal('Xtestfile1', @%) call assert_equal(2, line('.')) - call delete('Xerr') call delete('Xtestfile1') call delete('Xtestfile2') endfunc --- 4661,4666 ---- *************** *** 4731,4737 **** call s:create_test_file('Xtestfile2') Xexpr 'Xtestfile1:2:Line2' autocmd QuickFixCmdPost * Xolder ! call writefile(['Xtestfile2:4:Line4'], 'Xerr') Xfile Xerr call assert_equal('Xtestfile2', @%) call assert_equal(4, line('.')) --- 4680,4686 ---- call s:create_test_file('Xtestfile2') Xexpr 'Xtestfile1:2:Line2' autocmd QuickFixCmdPost * Xolder ! call writefile(['Xtestfile2:4:Line4'], 'Xerr', 'D') Xfile Xerr call assert_equal('Xtestfile2', @%) call assert_equal(4, line('.')) *************** *** 4802,4808 **** call assert_fails('silent Xvimgrep Line5 Xtestfile2', 'E480:') autocmd! QuickFixCmdPost - call delete('Xerr') call delete('Xtestfile1') call delete('Xtestfile2') endfunc --- 4751,4756 ---- *************** *** 4919,4925 **** " Test for parsing entries using visual screen column func Test_viscol() enew ! call writefile(["Col1\tCol2\tCol3"], 'Xfile1') edit Xfile1 " Use byte offset for column number --- 4867,4873 ---- " Test for parsing entries using visual screen column func Test_viscol() enew ! call writefile(["Col1\tCol2\tCol3"], 'Xfile1', 'D') edit Xfile1 " Use byte offset for column number *************** *** 4984,4990 **** enew | only set efm& - call delete('Xfile1') endfunc " Test for the quickfix window buffer --- 4932,4937 ---- *************** *** 5101,5114 **** " a normal buffer. func Test_empty_qfbuf() enew | only ! call writefile(["Test"], 'Xfile1') call setqflist([], 'f') copen | only let qfbuf = bufnr('') edit Xfile1 call assert_notequal(qfbuf, bufnr('')) enew - call delete('Xfile1') endfunc " Test for the :cbelow, :cabove, :lbelow and :labove commands. --- 5048,5060 ---- " a normal buffer. func Test_empty_qfbuf() enew | only ! call writefile(["Test"], 'Xfile1', 'D') call setqflist([], 'f') copen | only let qfbuf = bufnr('') edit Xfile1 call assert_notequal(qfbuf, bufnr('')) enew endfunc " Test for the :cbelow, :cabove, :lbelow and :labove commands. *************** *** 5341,5347 **** call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) " cfile/lfile ! call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1') let e = '' try Xfile Xfile1 --- 5287,5293 ---- call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) " cfile/lfile ! call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1', 'D') let e = '' try Xfile Xfile1 *************** *** 5350,5356 **** endtry call assert_equal('AbortCmd', e) call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) - call delete('Xfile1') " cgetbuffer/lgetbuffer enew! --- 5296,5301 ---- *************** *** 5414,5420 **** " Test for using a file in one of the parent directories. func Test_search_in_dirstack() ! call mkdir('Xtestdir/a/b/c', 'p') let save_cwd = getcwd() call writefile(["X1_L1", "X1_L2"], 'Xtestdir/Xfile1') call writefile(["X2_L1", "X2_L2"], 'Xtestdir/a/Xfile2') --- 5359,5365 ---- " Test for using a file in one of the parent directories. func Test_search_in_dirstack() ! call mkdir('Xtestdir/a/b/c', 'pR') let save_cwd = getcwd() call writefile(["X1_L1", "X1_L2"], 'Xtestdir/Xfile1') call writefile(["X2_L1", "X2_L2"], 'Xtestdir/a/Xfile2') *************** *** 5451,5457 **** set efm& exe 'cd ' . save_cwd - call delete('Xtestdir', 'rf') endfunc " Test for :cquit --- 5396,5401 ---- *************** *** 5895,5901 **** " Running :lhelpgrep command more than once in a help window, doesn't jump to " the help topic func Test_lhelpgrep_from_help_window() ! call mkdir('Xtestdir/doc', 'p') call writefile(['window'], 'Xtestdir/doc/a.txt') call writefile(['buffer'], 'Xtestdir/doc/b.txt') let save_rtp = &rtp --- 5839,5845 ---- " Running :lhelpgrep command more than once in a help window, doesn't jump to " the help topic func Test_lhelpgrep_from_help_window() ! call mkdir('Xtestdir/doc', 'pR') call writefile(['window'], 'Xtestdir/doc/a.txt') call writefile(['buffer'], 'Xtestdir/doc/b.txt') let save_rtp = &rtp *************** *** 5906,5912 **** lhelpgrep window call assert_equal('a.txt', fnamemodify(@%, ":p:t")) let &rtp = save_rtp - call delete('Xtestdir', 'rf') new | only! endfunc --- 5850,5855 ---- *************** *** 5993,5999 **** anything endtry END ! call writefile(lines, 'XquickfixFails') let lines =<< trim END split XquickfixFails --- 5936,5942 ---- anything endtry END ! call writefile(lines, 'XquickfixFails', 'D') let lines =<< trim END split XquickfixFails *************** *** 6004,6010 **** " is aborted but the window was already split. silent! cwindow END ! call writefile(lines, 'XtestWinFails') let buf = RunVimInTerminal('-S XtestWinFails', #{rows: 13}) call VerifyScreenDump(buf, 'Test_quickfix_window_fails', {}) --- 5947,5953 ---- " is aborted but the window was already split. silent! cwindow END ! call writefile(lines, 'XtestWinFails', 'D') let buf = RunVimInTerminal('-S XtestWinFails', #{rows: 13}) call VerifyScreenDump(buf, 'Test_quickfix_window_fails', {}) *************** *** 6012,6019 **** call term_sendkeys(buf, ":bwipe!\") call term_wait(buf) call StopVimInTerminal(buf) - call delete('XtestWinFails') - call delete('XquickfixFails') endfunc " Test for updating the quickfix buffer whenever the associated quickfix list --- 5955,5960 ---- *************** *** 6076,6086 **** func Test_vimgrep_noswapfile() set noswapfile ! call writefile(['one', 'two', 'three'], 'Xgreppie') vimgrep two Xgreppie call assert_equal('two', getline('.')) - call delete('Xgreppie') set swapfile endfunc --- 6017,6026 ---- func Test_vimgrep_noswapfile() set noswapfile ! call writefile(['one', 'two', 'three'], 'Xgreppie', 'D') vimgrep two Xgreppie call assert_equal('two', getline('.')) set swapfile endfunc *************** *** 6122,6133 **** endfunc func Test_vimgrep_fuzzy_match() ! call writefile(['one two three', 'aaaaaa'], 'Xfile1') ! call writefile(['one', 'three one two', 'two', 'aaathreeaaa'], 'Xfile2') call Xvimgrep_fuzzy_match('c') call Xvimgrep_fuzzy_match('l') - call delete('Xfile1') - call delete('Xfile2') endfunc func Test_locationlist_open_in_newtab() --- 6062,6071 ---- endfunc func Test_vimgrep_fuzzy_match() ! call writefile(['one two three', 'aaaaaa'], 'Xfile1', 'D') ! call writefile(['one', 'three one two', 'two', 'aaathreeaaa'], 'Xfile2', 'D') call Xvimgrep_fuzzy_match('c') call Xvimgrep_fuzzy_match('l') endfunc func Test_locationlist_open_in_newtab() *************** *** 6265,6276 **** call writefile(['done'], 'Xresult') qall! END ! call writefile(lines, 'Xscript') if RunVim([], [], '-u NONE -n -X -Z -e -m -s -S Xscript') call assert_equal(['done'], readfile('Xresult')) endif - call delete('Xscript') call delete('Xresult') endfunc --- 6203,6213 ---- call writefile(['done'], 'Xresult') qall! END ! call writefile(lines, 'Xscript', 'D') if RunVim([], [], '-u NONE -n -X -Z -e -m -s -S Xscript') call assert_equal(['done'], readfile('Xresult')) endif call delete('Xresult') endfunc *** ../vim-9.0.0668/src/testdir/test_recover.vim 2021-11-21 11:32:04.000000000 +0000 --- src/testdir/test_recover.vim 2022-10-05 21:41:08.547349356 +0100 *************** *** 140,148 **** call setline(1, ['a', 'b', 'c']) preserve let b = readblob(swapname('')) ! call writefile(b, '.Xfile1.swm') ! call writefile(b, '.Xfile1.swn') ! call writefile(b, '.Xfile1.swo') %bw! call feedkeys(":recover Xfile1\3\q", 'xt') call assert_equal(['a', 'b', 'c'], getline(1, '$')) --- 140,148 ---- call setline(1, ['a', 'b', 'c']) preserve let b = readblob(swapname('')) ! call writefile(b, '.Xfile1.swm', 'D') ! call writefile(b, '.Xfile1.swn', 'D') ! call writefile(b, '.Xfile1.swo', 'D') %bw! call feedkeys(":recover Xfile1\3\q", 'xt') call assert_equal(['a', 'b', 'c'], getline(1, '$')) *************** *** 156,171 **** call assert_equal('Xfile1', @%) call assert_equal([''], getline(1, '$')) bw! - - call delete('.Xfile1.swm') - call delete('.Xfile1.swn') - call delete('.Xfile1.swo') endfunc " Test for :recover using an empty swap file func Test_recover_empty_swap_file() CheckUnix ! call writefile([], '.Xfile1.swp') let msg = execute('recover Xfile1') call assert_match('Unable to read block 0 from .Xfile1.swp', msg) call assert_equal('Xfile1', @%) --- 156,167 ---- call assert_equal('Xfile1', @%) call assert_equal([''], getline(1, '$')) bw! endfunc " Test for :recover using an empty swap file func Test_recover_empty_swap_file() CheckUnix ! call writefile([], '.Xfile1.swp', 'D') let msg = execute('recover Xfile1') call assert_match('Unable to read block 0 from .Xfile1.swp', msg) call assert_equal('Xfile1', @%) *************** *** 178,184 **** " :recover from an empty buffer call assert_fails('recover', 'E305:') - call delete('.Xfile1.swp') endfunc " Test for :recover using a corrupted swap file --- 174,179 ---- *************** *** 366,376 **** CheckNotRoot new Xfile1 let b = readblob('.Xfile1.swp') ! call writefile(b, '.Xfile1.swm') bw! call setfperm('.Xfile1.swm', '-w-------') call assert_fails('recover Xfile1', 'E306:') - call delete('.Xfile1.swm') endfunc " Test for using :recover when the original file and the swap file have the --- 361,370 ---- CheckNotRoot new Xfile1 let b = readblob('.Xfile1.swp') ! call writefile(b, '.Xfile1.swm', 'D') bw! call setfperm('.Xfile1.swm', '-w-------') call assert_fails('recover Xfile1', 'E306:') endfunc " Test for using :recover when the original file and the swap file have the *************** *** 382,401 **** preserve let b = readblob('.Xfile1.swp') %bw! ! call writefile(b, '.Xfile1.swz') let msg = execute('recover Xfile1') call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) call assert_false(&modified) call assert_match('Buffer contents equals file contents', msg) bw! call delete('Xfile1') - call delete('.Xfile1.swz') endfunc " Test for recovering a file when editing a symbolically linked file func Test_recover_symbolic_link() CheckUnix ! call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1') silent !ln -s Xfile1 Xfile2 edit Xfile2 call assert_equal('.Xfile1.swp', fnamemodify(swapname(''), ':t')) --- 376,394 ---- preserve let b = readblob('.Xfile1.swp') %bw! ! call writefile(b, '.Xfile1.swz', 'D') let msg = execute('recover Xfile1') call assert_equal(['aaa', 'bbb', 'ccc'], getline(1, '$')) call assert_false(&modified) call assert_match('Buffer contents equals file contents', msg) bw! call delete('Xfile1') endfunc " Test for recovering a file when editing a symbolically linked file func Test_recover_symbolic_link() CheckUnix ! call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1', 'D') silent !ln -s Xfile1 Xfile2 edit Xfile2 call assert_equal('.Xfile1.swp', fnamemodify(swapname(''), ':t')) *************** *** 410,416 **** update %bw! call assert_equal(['aaa', 'bbb', 'ccc'], readfile('Xfile1')) - call delete('Xfile1') call delete('Xfile2') call delete('.Xfile1.swp') endfunc --- 403,408 ---- *************** *** 419,425 **** " line. This used to result in an internal error (E315) which is fixed " by 8.2.2966. func Test_recover_invalid_cursor_pos() ! call writefile([], 'Xfile1') edit Xfile1 preserve let b = readblob('.Xfile1.swp') --- 411,417 ---- " line. This used to result in an internal error (E315) which is fixed " by 8.2.2966. func Test_recover_invalid_cursor_pos() ! call writefile([], 'Xfile1', 'D') edit Xfile1 preserve let b = readblob('.Xfile1.swp') *************** *** 429,435 **** au BufReadPost Xfile1 normal! 3G augroup END call writefile(range(1, 3), 'Xfile1') ! call writefile(b, '.Xfile1.swp') try recover Xfile1 catch /E308:/ --- 421,427 ---- au BufReadPost Xfile1 normal! 3G augroup END call writefile(range(1, 3), 'Xfile1') ! call writefile(b, '.Xfile1.swp', 'D') try recover Xfile1 catch /E308:/ *************** *** 441,448 **** au! augroup END augroup! Test - call delete('Xfile1') - call delete('.Xfile1.swp') endfunc " Test for recovering a buffer without a name --- 433,438 ---- *************** *** 453,462 **** let sn = swapname('') let b = readblob(sn) bw! ! call writefile(b, sn) exe "recover " .. sn call assert_equal(['one', 'two'], getline(1, '$')) - call delete(sn) endfunc " vim: shiftwidth=2 sts=2 expandtab --- 443,451 ---- let sn = swapname('') let b = readblob(sn) bw! ! call writefile(b, sn, 'D') exe "recover " .. sn call assert_equal(['one', 'two'], getline(1, '$')) endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0668/src/testdir/test_regexp_utf8.vim 2022-07-29 18:32:17.468531163 +0100 --- src/testdir/test_regexp_utf8.vim 2022-10-05 21:35:39.223314581 +0100 *************** *** 555,574 **** endfunc func Test_match_invalid_byte() ! call writefile(0z630a.765d30aa0a.2e0a.790a.4030, 'Xinvalid') new source Xinvalid bwipe! - call delete('Xinvalid') endfunc func Test_match_illegal_byte() " Text has illegal bytes which need to be set explicitly let lines = ["norm :set no\x01\", "silent n\xff", "silent norm :b\xff\"] ! call writefile(lines, 'Xregexp') call system(GetVimCommand() .. ' -X -Z -e -s -S Xregexp -c qa!') - - call delete('Xregexp') endfunc func Test_match_too_complicated() --- 555,571 ---- endfunc func Test_match_invalid_byte() ! call writefile(0z630a.765d30aa0a.2e0a.790a.4030, 'Xinvalid', 'D') new source Xinvalid bwipe! endfunc func Test_match_illegal_byte() " Text has illegal bytes which need to be set explicitly let lines = ["norm :set no\x01\", "silent n\xff", "silent norm :b\xff\"] ! call writefile(lines, 'Xregexp', 'D') call system(GetVimCommand() .. ' -X -Z -e -s -S Xregexp -c qa!') endfunc func Test_match_too_complicated() *** ../vim-9.0.0668/src/testdir/test_rename.vim 2020-09-04 20:11:04.000000000 +0100 --- src/testdir/test_rename.vim 2022-10-05 21:43:34.579239896 +0100 *************** *** 12,18 **** " When the destination file already exists, it should be overwritten. call writefile(['foo'], 'Xrename1') ! call writefile(['bar'], 'Xrename2') call assert_equal(0, rename('Xrename1', 'Xrename2')) call assert_equal('', glob('Xrename1')) --- 12,18 ---- " When the destination file already exists, it should be overwritten. call writefile(['foo'], 'Xrename1') ! call writefile(['bar'], 'Xrename2', 'D') call assert_equal(0, rename('Xrename1', 'Xrename2')) call assert_equal('', glob('Xrename1')) *************** *** 36,42 **** endfunc func Test_rename_same_file() ! call writefile(['foo'], 'Xrename') " When the source and destination are the same file, nothing " should be done. The source file should not be deleted. --- 36,42 ---- endfunc func Test_rename_same_file() ! call writefile(['foo'], 'Xrename', 'D') " When the source and destination are the same file, nothing " should be done. The source file should not be deleted. *************** *** 45,52 **** call assert_equal(0, rename('./Xrename', 'Xrename')) call assert_equal(['foo'], readfile('Xrename')) - - call delete('Xrename') endfunc func Test_rename_dir_to_dir() --- 45,50 ---- *************** *** 63,83 **** endfunc func Test_rename_same_dir() ! call mkdir('Xrenamedir') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call assert_equal(0, rename('Xrenamedir', 'Xrenamedir')) call assert_equal(['foo'], readfile('Xrenamedir/Xrenamefile')) - - call delete('Xrenamedir/Xrenamefile') - call delete('Xrenamedir', 'd') endfunc func Test_rename_copy() " Check that when original file can't be deleted, rename() " still succeeds but copies the file. ! call mkdir('Xrenamedir') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call setfperm('Xrenamedir', 'r-xr-xr-x') --- 61,78 ---- endfunc func Test_rename_same_dir() ! call mkdir('Xrenamedir', 'R') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call assert_equal(0, rename('Xrenamedir', 'Xrenamedir')) call assert_equal(['foo'], readfile('Xrenamedir/Xrenamefile')) endfunc func Test_rename_copy() " Check that when original file can't be deleted, rename() " still succeeds but copies the file. ! call mkdir('Xrenamedir', 'R') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call setfperm('Xrenamedir', 'r-xr-xr-x') *************** *** 91,103 **** call assert_equal(['foo'], readfile('Xrenamefile')) call setfperm('Xrenamedir', 'rwxrwxrwx') - call delete('Xrenamedir/Xrenamefile') - call delete('Xrenamedir', 'd') call delete('Xrenamefile') endfunc func Test_rename_fails() ! call writefile(['foo'], 'Xrenamefile') " Can't rename into a non-existing directory. call assert_notequal(0, rename('Xrenamefile', 'Xdoesnotexist/Xrenamefile')) --- 86,96 ---- call assert_equal(['foo'], readfile('Xrenamefile')) call setfperm('Xrenamedir', 'rwxrwxrwx') call delete('Xrenamefile') endfunc func Test_rename_fails() ! call writefile(['foo'], 'Xrenamefile', 'D') " Can't rename into a non-existing directory. call assert_notequal(0, rename('Xrenamefile', 'Xdoesnotexist/Xrenamefile')) *************** *** 115,122 **** call assert_fails('call rename("Xrenamefile", [])', 'E730:') call assert_fails('call rename(0z, "Xrenamefile")', 'E976:') - - call delete('Xrenamefile') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 108,113 ---- *** ../vim-9.0.0668/src/testdir/test_restricted.vim 2022-02-01 17:22:29.000000000 +0000 --- src/testdir/test_restricted.vim 2022-10-05 21:38:13.499390121 +0100 *************** *** 101,107 **** call writefile(v:errors, 'Xresult') qa! END ! call writefile(lines, 'Xrestricted') if RunVim([], [], '-Z --clean -S Xrestricted') call assert_equal([], readfile('Xresult')) endif --- 101,107 ---- call writefile(v:errors, 'Xresult') qa! END ! call writefile(lines, 'Xrestricted', 'D') if RunVim([], [], '-Z --clean -S Xrestricted') call assert_equal([], readfile('Xresult')) endif *************** *** 114,120 **** call assert_equal([], readfile('Xresult')) endif - call delete('Xrestricted') call delete('Xresult') endfunc --- 114,119 ---- *** ../vim-9.0.0668/src/version.c 2022-10-05 20:40:57.756281224 +0100 --- src/version.c 2022-10-05 21:44:03.823211461 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 669, /**/ -- Facepalm statement #2: "If there is a country without immigrants I'm going to move there" /// 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 ///