To: vim_dev@googlegroups.com Subject: Patch 9.0.0619 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0619 Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible. Files: src/testdir/test_gf.vim, src/testdir/test_global.vim, src/testdir/test_gui.vim, src/testdir/test_help.vim, src/testdir/test_highlight.vim *** ../vim-9.0.0618/src/testdir/test_gf.vim 2022-09-02 21:55:45.503049444 +0100 --- src/testdir/test_gf.vim 2022-09-28 20:55:43.716646225 +0100 *************** *** 88,98 **** func Test_gf() set isfname=@,48-57,/,.,-,_,+,,,$,:,~,{,} ! call writefile(["Test for gf command"], "Xtest1") if has("unix") ! call writefile([" ${CDIR}/Xtest1"], "Xtestgf") else ! call writefile([" $TDIR/Xtest1"], "Xtestgf") endif new Xtestgf if has("unix") --- 88,98 ---- func Test_gf() set isfname=@,48-57,/,.,-,_,+,,,$,:,~,{,} ! call writefile(["Test for gf command"], "Xtest1", 'D') if has("unix") ! call writefile([" ${CDIR}/Xtest1"], "Xtestgf", 'D') else ! call writefile([" $TDIR/Xtest1"], "Xtestgf", 'D') endif new Xtestgf if has("unix") *************** *** 109,122 **** normal gf call assert_equal('Xtest1', fnamemodify(bufname(''), ":t")) - close! ! call delete('Xtest1') ! call delete('Xtestgf') endfunc func Test_gf_visual() ! call writefile(['one', 'two', 'three', 'four'], "Xtest_gf_visual") new call setline(1, 'XXXtest_gf_visualXXX') set hidden --- 109,120 ---- normal gf call assert_equal('Xtest1', fnamemodify(bufname(''), ":t")) ! close! endfunc func Test_gf_visual() ! call writefile(['one', 'two', 'three', 'four'], "Xtest_gf_visual", 'D') new call setline(1, 'XXXtest_gf_visualXXX') set hidden *************** *** 139,171 **** call assert_equal(3, getcurpos()[1]) " do not include the NUL at the end ! call writefile(['x'], 'X') let save_enc = &enc for enc in ['latin1', 'utf-8'] exe "set enc=" .. enc new ! call setline(1, 'X') set nomodified exe "normal \$gf" ! call assert_equal('X', bufname()) bwipe! endfor let &enc = save_enc - call delete('X') " line number in visual area is used for file name if has('unix') bwipe! ! call writefile([], "Xtest_gf_visual:3") new call setline(1, 'XXXtest_gf_visual:3XXX') norm! 0ttvtXgF call assert_equal('Xtest_gf_visual:3', bufname('%')) - call delete('Xtest_gf_visual:3') endif bwipe! - call delete('Xtest_gf_visual') set hidden& endfunc --- 137,166 ---- call assert_equal(3, getcurpos()[1]) " do not include the NUL at the end ! call writefile(['x'], 'Xvisual', 'D') let save_enc = &enc for enc in ['latin1', 'utf-8'] exe "set enc=" .. enc new ! call setline(1, 'Xvisual') set nomodified exe "normal \$gf" ! call assert_equal('Xvisual', bufname()) bwipe! endfor let &enc = save_enc " line number in visual area is used for file name if has('unix') bwipe! ! call writefile([], "Xtest_gf_visual:3", 'D') new call setline(1, 'XXXtest_gf_visual:3XXX') norm! 0ttvtXgF call assert_equal('Xtest_gf_visual:3', bufname('%')) endif bwipe! set hidden& endfunc *************** *** 254,260 **** func Test_gf_subdirs_wildcard() let cwd = getcwd() let dir = 'Xtestgf_dir' ! call mkdir(dir) call chdir(dir) for i in range(300) call mkdir(i) --- 249,255 ---- func Test_gf_subdirs_wildcard() let cwd = getcwd() let dir = 'Xtestgf_dir' ! call mkdir(dir, 'R') call chdir(dir) for i in range(300) call mkdir(i) *************** *** 269,275 **** call assert_equal('99', fnamemodify(bufname(''), ":t")) call chdir(cwd) - call delete(dir, 'rf') set path& endfunc --- 264,269 ---- *** ../vim-9.0.0618/src/testdir/test_global.vim 2022-09-27 18:05:35.071074039 +0100 --- src/testdir/test_global.vim 2022-09-28 20:55:55.916627798 +0100 *************** *** 116,122 **** cnoremap ; sleep 10 call setline(1, repeat(['foo'], 5)) END ! call writefile(lines, 'Xtest_interrupt_global') let buf = RunVimInTerminal('-S Xtest_interrupt_global', {'rows': 6}) call term_sendkeys(buf, ":g/foo/norm :\;\") --- 116,122 ---- cnoremap ; sleep 10 call setline(1, repeat(['foo'], 5)) END ! call writefile(lines, 'Xtest_interrupt_global', 'D') let buf = RunVimInTerminal('-S Xtest_interrupt_global', {'rows': 6}) call term_sendkeys(buf, ":g/foo/norm :\;\") *************** *** 133,139 **** call WaitForAssert({-> assert_match('Interrupted', term_getline(buf, 5))}, 1000) call StopVimInTerminal(buf) - call delete('Xtest_interrupt_global') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 133,138 ---- *** ../vim-9.0.0618/src/testdir/test_gui.vim 2022-09-09 17:38:58.836061268 +0100 --- src/testdir/test_gui.vim 2022-09-28 20:57:39.852467406 +0100 *************** *** 157,168 **** func Test_gui_read_stdin() CheckUnix ! call writefile(['some', 'lines'], 'Xstdin') let script =<< trim END call writefile(getline(1, '$'), 'XstdinOK') qa! END ! call writefile(script, 'Xscript') " Cannot use --not-a-term here, the "reading from stdin" message would not be " displayed. --- 157,168 ---- func Test_gui_read_stdin() CheckUnix ! call writefile(['some', 'lines'], 'Xstdin', 'D') let script =<< trim END call writefile(getline(1, '$'), 'XstdinOK') qa! END ! call writefile(script, 'Xscript', 'D') " Cannot use --not-a-term here, the "reading from stdin" message would not be " displayed. *************** *** 176,184 **** call system('cat Xstdin | ' .. vimcmd .. ' -f -g -S Xscript -') call assert_equal(['some', 'lines'], readfile('XstdinOK')) - call delete('Xstdin') call delete('XstdinOK') - call delete('Xscript') endfunc func Test_set_background() --- 176,182 ---- *************** *** 853,885 **** " Test "vim -g" and also the GUIEnter autocommand. func Test_gui_dash_g() let cmd = GetVimCommand('Xscriptgui') ! call writefile([""], "Xtestgui") let lines =<< trim END au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") au GUIEnter * qall END ! call writefile(lines, 'Xscriptgui') call system(cmd . ' -g') call WaitForAssert({-> assert_equal(['insertmode: 0'], readfile('Xtestgui'))}) - - call delete('Xscriptgui') - call delete('Xtestgui') endfunc " Test "vim -7" and also the GUIEnter autocommand. func Test_gui_dash_y() let cmd = GetVimCommand('Xscriptgui') ! call writefile([""], "Xtestgui") let lines =<< trim END au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") au GUIEnter * qall END ! call writefile(lines, 'Xscriptgui') call system(cmd . ' -y') call WaitForAssert({-> assert_equal(['insertmode: 1'], readfile('Xtestgui'))}) - - call delete('Xscriptgui') - call delete('Xtestgui') endfunc " Test for "!" option in 'guioptions'. Use a terminal for running external --- 851,877 ---- " Test "vim -g" and also the GUIEnter autocommand. func Test_gui_dash_g() let cmd = GetVimCommand('Xscriptgui') ! call writefile([""], "Xtestgui", 'D') let lines =<< trim END au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") au GUIEnter * qall END ! call writefile(lines, 'Xscriptgui', 'D') call system(cmd . ' -g') call WaitForAssert({-> assert_equal(['insertmode: 0'], readfile('Xtestgui'))}) endfunc " Test "vim -7" and also the GUIEnter autocommand. func Test_gui_dash_y() let cmd = GetVimCommand('Xscriptgui') ! call writefile([""], "Xtestgui", 'D') let lines =<< trim END au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") au GUIEnter * qall END ! call writefile(lines, 'Xscriptgui', 'D') call system(cmd . ' -y') call WaitForAssert({-> assert_equal(['insertmode: 1'], readfile('Xtestgui'))}) endfunc " Test for "!" option in 'guioptions'. Use a terminal for running external *************** *** 1412,1418 **** %argdelete " pressing shift when dropping files should change directory let save_cwd = getcwd() ! call mkdir('Xdropdir1') call writefile([], 'Xdropdir1/Xfile1') call writefile([], 'Xdropdir1/Xfile2') let d = #{files: ['Xdropdir1/Xfile1', 'Xdropdir1/Xfile2'], row: 1, col: 1, --- 1404,1410 ---- %argdelete " pressing shift when dropping files should change directory let save_cwd = getcwd() ! call mkdir('Xdropdir1', 'R') call writefile([], 'Xdropdir1/Xfile1') call writefile([], 'Xdropdir1/Xfile2') let d = #{files: ['Xdropdir1/Xfile1', 'Xdropdir1/Xfile2'], row: 1, col: 1, *************** *** 1441,1447 **** call assert_equal('', @%) %bw! %argdelete - call delete('Xdropdir1', 'rf') " drop files in the command line. The GUI drop files adds the file names to " the low level input buffer. So need to use a cmdline map and feedkeys() --- 1433,1438 ---- *** ../vim-9.0.0618/src/testdir/test_help.vim 2022-08-29 22:31:15.919685279 +0100 --- src/testdir/test_help.vim 2022-09-28 20:59:39.056276921 +0100 *************** *** 77,83 **** endfunc func Test_help_local_additions() ! call mkdir('Xruntime/doc', 'p') call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt') call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') let rtp_save = &rtp --- 77,83 ---- endfunc func Test_help_local_additions() ! call mkdir('Xruntime/doc', 'pR') call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt') call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') let rtp_save = &rtp *************** *** 91,97 **** call delete('Xruntime/doc/mydoc-ext.txt') close ! call mkdir('Xruntime-ja/doc', 'p') call writefile(["local-additions\thelp.jax\t/*local-additions*"], 'Xruntime-ja/doc/tags-ja') call writefile(['*help.txt* This is jax file', '', \ 'LOCAL ADDITIONS: *local-additions*', ''], 'Xruntime-ja/doc/help.jax') --- 91,97 ---- call delete('Xruntime/doc/mydoc-ext.txt') close ! call mkdir('Xruntime-ja/doc', 'pR') call writefile(["local-additions\thelp.jax\t/*local-additions*"], 'Xruntime-ja/doc/tags-ja') call writefile(['*help.txt* This is jax file', '', \ 'LOCAL ADDITIONS: *local-additions*', ''], 'Xruntime-ja/doc/help.jax') *************** *** 116,123 **** \ ], lines) close - call delete('Xruntime', 'rf') - call delete('Xruntime-ja', 'rf') let &rtp = rtp_save endfunc --- 116,121 ---- *************** *** 129,135 **** " Test for the :helptags command " NOTE: if you run tests as root this will fail. Don't run tests as root! func Test_helptag_cmd() ! call mkdir('Xtagdir/a/doc', 'p') " No help file to process in the directory call assert_fails('helptags Xtagdir', 'E151:') --- 127,133 ---- " Test for the :helptags command " NOTE: if you run tests as root this will fail. Don't run tests as root! func Test_helptag_cmd() ! call mkdir('Xtagdir/a/doc', 'pR') " No help file to process in the directory call assert_fails('helptags Xtagdir', 'E151:') *************** *** 151,158 **** " Duplicate tags in the help file call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xtagdir/a/doc/sample.txt') call assert_fails('helptags Xtagdir', 'E154:') - - call delete('Xtagdir', 'rf') endfunc func Test_helptag_cmd_readonly() --- 149,154 ---- *************** *** 160,166 **** CheckNotRoot " Read-only tags file ! call mkdir('Xrodir/doc', 'p') call writefile([''], 'Xrodir/doc/tags') call writefile([], 'Xrodir/doc/sample.txt') call setfperm('Xrodir/doc/tags', 'r-xr--r--') --- 156,162 ---- CheckNotRoot " Read-only tags file ! call mkdir('Xrodir/doc', 'pR') call writefile([''], 'Xrodir/doc/tags') call writefile([], 'Xrodir/doc/sample.txt') call setfperm('Xrodir/doc/tags', 'r-xr--r--') *************** *** 178,184 **** call writefile([], 'Xrodir/b/doc/sample.txt') call setfperm('Xrodir/b/doc/sample.txt', '-w-------') call assert_fails('helptags Xrodir', 'E153:', getfperm('Xrodir/b/doc/sample.txt')) - call delete('Xrodir', 'rf') endfunc " Test for setting the 'helpheight' option in the help window --- 174,179 ---- *** ../vim-9.0.0618/src/testdir/test_highlight.vim 2022-06-29 18:39:05.015841419 +0100 --- src/testdir/test_highlight.vim 2022-09-28 21:03:44.999182112 +0100 *************** *** 540,546 **** call writefile([ \ 'set cul rnu', \ 'call setline(1, ["","1","2","3",""])', ! \ ], 'Xtest_cursorline_yank') let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8}) call TermWait(buf) call term_sendkeys(buf, "Gy3k") --- 540,546 ---- call writefile([ \ 'set cul rnu', \ 'call setline(1, ["","1","2","3",""])', ! \ ], 'Xtest_cursorline_yank', 'D') let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8}) call TermWait(buf) call term_sendkeys(buf, "Gy3k") *************** *** 551,557 **** " clean up call StopVimInTerminal(buf) - call delete('Xtest_cursorline_yank') endfunc " test for issue #4862 --- 551,556 ---- *************** *** 580,586 **** call writefile([ \ 'set cul', \ 'call setline(1, repeat(["abc"], 50))', ! \ ], 'Xtest_cursorline_with_visualmode') let buf = RunVimInTerminal('-S Xtest_cursorline_with_visualmode', {'rows': 12}) call TermWait(buf) call term_sendkeys(buf, "V\kkkjk") --- 579,585 ---- call writefile([ \ 'set cul', \ 'call setline(1, repeat(["abc"], 50))', ! \ ], 'Xtest_cursorline_with_visualmode', 'D') let buf = RunVimInTerminal('-S Xtest_cursorline_with_visualmode', {'rows': 12}) call TermWait(buf) call term_sendkeys(buf, "V\kkkjk") *************** *** 589,595 **** " clean up call StopVimInTerminal(buf) - call delete('Xtest_cursorline_with_visualmode') endfunc func Test_cursorcolumn_insert_on_tab() --- 588,593 ---- *************** *** 600,606 **** set cursorcolumn call cursor(2, 2) END ! call writefile(lines, 'Xcuc_insert_on_tab') let buf = RunVimInTerminal('-S Xcuc_insert_on_tab', #{rows: 8}) call TermWait(buf) --- 598,604 ---- set cursorcolumn call cursor(2, 2) END ! call writefile(lines, 'Xcuc_insert_on_tab', 'D') let buf = RunVimInTerminal('-S Xcuc_insert_on_tab', #{rows: 8}) call TermWait(buf) *************** *** 619,625 **** call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_2', {}) call StopVimInTerminal(buf) - call delete('Xcuc_insert_on_tab') endfunc func Test_cursorcolumn_callback() --- 617,622 ---- *************** *** 637,650 **** call timer_start(300, 'Func') END ! call writefile(lines, 'Xcuc_timer') let buf = RunVimInTerminal('-S Xcuc_timer', #{rows: 8}) call TermWait(buf, 310) call VerifyScreenDump(buf, 'Test_cursorcolumn_callback_1', {}) call StopVimInTerminal(buf) - call delete('Xcuc_timer') endfunc func Test_wincolor() --- 634,646 ---- call timer_start(300, 'Func') END ! call writefile(lines, 'Xcuc_timer', 'D') let buf = RunVimInTerminal('-S Xcuc_timer', #{rows: 8}) call TermWait(buf, 310) call VerifyScreenDump(buf, 'Test_cursorcolumn_callback_1', {}) call StopVimInTerminal(buf) endfunc func Test_wincolor() *************** *** 663,669 **** call prop_add(6, 12, {"type": "foo", "end_col": 15}) /here END ! call writefile(lines, 'Xtest_wincolor') let buf = RunVimInTerminal('-S Xtest_wincolor', {'rows': 8}) call TermWait(buf) call term_sendkeys(buf, "2G5lvj") --- 659,665 ---- call prop_add(6, 12, {"type": "foo", "end_col": 15}) /here END ! call writefile(lines, 'Xtest_wincolor', 'D') let buf = RunVimInTerminal('-S Xtest_wincolor', {'rows': 8}) call TermWait(buf) call term_sendkeys(buf, "2G5lvj") *************** *** 674,680 **** " clean up call term_sendkeys(buf, "\") call StopVimInTerminal(buf) - call delete('Xtest_wincolor') endfunc func Test_wincolor_listchars() --- 670,675 ---- *************** *** 689,695 **** call matchadd('Conceal', 'text') normal 2G5zl END ! call writefile(lines, 'Xtest_wincolorlcs') let buf = RunVimInTerminal('-S Xtest_wincolorlcs', {'rows': 8}) call VerifyScreenDump(buf, 'Test_wincolor_lcs', {}) --- 684,690 ---- call matchadd('Conceal', 'text') normal 2G5zl END ! call writefile(lines, 'Xtest_wincolorlcs', 'D') let buf = RunVimInTerminal('-S Xtest_wincolorlcs', {'rows': 8}) call VerifyScreenDump(buf, 'Test_wincolor_lcs', {}) *************** *** 697,703 **** " clean up call term_sendkeys(buf, "\") call StopVimInTerminal(buf) - call delete('Xtest_wincolorlcs') endfunc func Test_colorcolumn() --- 692,697 ---- *************** *** 714,727 **** wincmd w buf X END ! call writefile(lines, 'Xtest_colorcolumn') let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10}) call term_sendkeys(buf, ":\") call VerifyScreenDump(buf, 'Test_colorcolumn_1', {}) " clean up call StopVimInTerminal(buf) - call delete('Xtest_colorcolumn') endfunc func Test_colorcolumn_bri() --- 708,720 ---- wincmd w buf X END ! call writefile(lines, 'Xtest_colorcolumn', 'D') let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10}) call term_sendkeys(buf, ":\") call VerifyScreenDump(buf, 'Test_colorcolumn_1', {}) " clean up call StopVimInTerminal(buf) endfunc func Test_colorcolumn_bri() *************** *** 731,744 **** let lines =<< trim END call setline(1, 'The quick brown fox jumped over the lazy dogs') END ! call writefile(lines, 'Xtest_colorcolumn_bri') let buf = RunVimInTerminal('-S Xtest_colorcolumn_bri', {'rows': 10,'columns': 40}) call term_sendkeys(buf, ":set co=40 linebreak bri briopt=shift:2 cc=40,41,43\") call VerifyScreenDump(buf, 'Test_colorcolumn_2', {}) " clean up call StopVimInTerminal(buf) - call delete('Xtest_colorcolumn_bri') endfunc func Test_colorcolumn_sbr() --- 724,736 ---- let lines =<< trim END call setline(1, 'The quick brown fox jumped over the lazy dogs') END ! call writefile(lines, 'Xtest_colorcolumn_bri', 'D') let buf = RunVimInTerminal('-S Xtest_colorcolumn_bri', {'rows': 10,'columns': 40}) call term_sendkeys(buf, ":set co=40 linebreak bri briopt=shift:2 cc=40,41,43\") call VerifyScreenDump(buf, 'Test_colorcolumn_2', {}) " clean up call StopVimInTerminal(buf) endfunc func Test_colorcolumn_sbr() *************** *** 748,761 **** let lines =<< trim END call setline(1, 'The quick brown fox jumped over the lazy dogs') END ! call writefile(lines, 'Xtest_colorcolumn_srb') let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40}) call term_sendkeys(buf, ":set co=40 showbreak=+++>\\ cc=40,41,43\") call VerifyScreenDump(buf, 'Test_colorcolumn_3', {}) " clean up call StopVimInTerminal(buf) - call delete('Xtest_colorcolumn_srb') endfunc " This test must come before the Test_cursorline test, as it appears this --- 740,752 ---- let lines =<< trim END call setline(1, 'The quick brown fox jumped over the lazy dogs') END ! call writefile(lines, 'Xtest_colorcolumn_srb', 'D') let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40}) call term_sendkeys(buf, ":set co=40 showbreak=+++>\\ cc=40,41,43\") call VerifyScreenDump(buf, 'Test_colorcolumn_3', {}) " clean up call StopVimInTerminal(buf) endfunc " This test must come before the Test_cursorline test, as it appears this *** ../vim-9.0.0618/src/version.c 2022-09-28 16:16:10.256335629 +0100 --- src/version.c 2022-09-28 21:05:21.002680079 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 619, /**/ -- hundred-and-one symptoms of being an internet addict: 215. Your mouse-clicking forearm rivals Popeye's. /// 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 ///