Patch 9.0.0769
Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.
Files:      src/testdir/test_winbar.vim, src/testdir/test_winbuf_close.vim,
            src/testdir/test_window_cmd.vim, src/testdir/test_writefile.vim,
            src/testdir/test_xxd.vim


*** ../vim-9.0.0768/src/testdir/test_winbar.vim 2022-05-20 13:43:55.000000000 
+0100
--- src/testdir/test_winbar.vim 2022-10-15 21:47:40.643148989 +0100
***************
*** 132,144 ****
        wincmd j
        wincmd _
    END
!   call writefile(lines, 'XtestWinbarNotVisble')
    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()
--- 132,143 ----
        wincmd j
        wincmd _
    END
!   call writefile(lines, 'XtestWinbarNotVisble', 'D')
    let buf = RunVimInTerminal('-S XtestWinbarNotVisble', #{rows: 10})
    call VerifyScreenDump(buf, 'Test_winbar_not_visible', {})
  
    " clean up
    call StopVimInTerminal(buf)
  endfunction
  
  func Test_winbar_not_visible_custom_statusline()
***************
*** 152,164 ****
        wincmd j
        wincmd _
    END
!   call writefile(lines, 'XtestWinbarNotVisble')
    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()
--- 151,162 ----
        wincmd j
        wincmd _
    END
!   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)
  endfunction
  
  func Test_drag_statusline_with_winbar()
*** ../vim-9.0.0768/src/testdir/test_winbuf_close.vim   2020-09-26 
18:07:35.000000000 +0100
--- src/testdir/test_winbuf_close.vim   2022-10-15 21:48:14.407137068 +0100
***************
*** 12,20 ****
  func Test_winbuf_close()
    enew | only
  
!   call writefile(['testtext 1'], 'Xtest1')
!   call writefile(['testtext 2'], 'Xtest2')
!   call writefile(['testtext 3'], 'Xtest3')
  
    next! Xtest1 Xtest2
    call setline(1, 'testtext 1 1')
--- 12,20 ----
  func Test_winbuf_close()
    enew | only
  
!   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,126 ****
    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.
--- 117,122 ----
*** ../vim-9.0.0768/src/testdir/test_window_cmd.vim     2022-10-05 
18:25:26.937192709 +0100
--- src/testdir/test_window_cmd.vim     2022-10-15 21:49:33.795109042 +0100
***************
*** 69,76 ****
  func Test_window_cmd_wincmd_gf()
    let fname = 'test_gf.txt'
    let swp_fname = '.' . fname . '.swp'
!   call writefile([], fname)
!   call writefile([], swp_fname)
    function s:swap_exists()
      let v:swapchoice = s:swap_choice
    endfunc
--- 69,76 ----
  func Test_window_cmd_wincmd_gf()
    let fname = 'test_gf.txt'
    let swp_fname = '.' . fname . '.swp'
!   call writefile([], fname, 'D')
!   call writefile([], swp_fname, 'D')
    function s:swap_exists()
      let v:swapchoice = s:swap_choice
    endfunc
***************
*** 96,103 ****
    call assert_notequal(fname, bufname("%"))
    new | only!
  
-   call delete(fname)
-   call delete(swp_fname)
    augroup! test_window_cmd_wincmd_gf
  endfunc
  
--- 96,101 ----
***************
*** 740,746 ****
    CheckUnix
  
    set hidden autoread
!   call writefile(['2'], 'tmp.txt')
    new tmp.txt
    q
    call Fun_RenewFile()
--- 738,744 ----
    CheckUnix
  
    set hidden autoread
!   call writefile(['2'], 'tmp.txt', 'D')
    new tmp.txt
    q
    call Fun_RenewFile()
***************
*** 756,762 ****
    wincmd p
    " reset
    q
-   call delete('tmp.txt')
    set hidden&vim autoread&vim
    delfunc Fun_RenewFile
  endfunc
--- 754,759 ----
***************
*** 1082,1090 ****
      endtry
    endwhile
  
!   call writefile(['first', 'second', 'third'], 'Xnorfile1')
!   call writefile([], 'Xnorfile2')
!   call writefile([], 'Xnorfile3')
  
    " Argument list related commands
    args Xnorfile1 Xnorfile2 Xnorfile3
--- 1079,1087 ----
      endtry
    endwhile
  
!   call writefile(['first', 'second', 'third'], 'Xnorfile1', 'D')
!   call writefile([], 'Xnorfile2', 'D')
!   call writefile([], 'Xnorfile3', 'D')
  
    " Argument list related commands
    args Xnorfile1 Xnorfile2 Xnorfile3
***************
*** 1165,1173 ****
    endif
  
    %bwipe!
-   call delete('Xnorfile1')
-   call delete('Xnorfile2')
-   call delete('Xnorfile3')
    only
  endfunc
  
--- 1162,1167 ----
*** ../vim-9.0.0768/src/testdir/test_writefile.vim      2022-09-20 
11:49:06.007787298 +0100
--- src/testdir/test_writefile.vim      2022-10-15 21:55:07.866991584 +0100
***************
*** 5,12 ****
  
  func Test_writefile()
    let f = tempname()
!   call writefile(["over","written"], f, "b")
!   call writefile(["hello","world"], f, "b")
    call writefile(["!", "good"], f, "a")
    call writefile(["morning"], f, "ab")
    call writefile(["", "vimmers"], f, "ab")
--- 5,12 ----
  
  func Test_writefile()
    let f = tempname()
!   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,22 ****
    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
--- 16,21 ----
***************
*** 52,58 ****
    set nobackup nowritebackup backupdir=. backupskip=
    new
    let contents = ["line one", "line two"]
!   call writefile(contents, 'Xwfcfile')
    edit Xwfcfile
    call setline(1, ["first line", "cannot convert \u010b", "third line"])
    call assert_fails('write ++enc=cp932', 'E513:')
--- 51,57 ----
    set nobackup nowritebackup backupdir=. backupskip=
    new
    let contents = ["line one", "line two"]
!   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,85 ****
    call delete('Xwfcfily~')
    %bw!
  
-   call delete('Xwfcfile')
    call delete('Xwfcfile' .. &backupext)
    bwipe!
    set backup& writebackup& backupdir&vim backupskip&vim
--- 78,83 ----
***************
*** 94,100 ****
    " but then the backup file must remain
    set nobackup writebackup backupdir=. backupskip=
    let contents = ["line one", "line two"]
!   call writefile(contents, 'Xwf2file_conversion_err')
    edit Xwf2file_conversion_err
    call setline(1, ["first line", "cannot convert \u010b", "third line"])
    set fileencoding=latin1
--- 92,98 ----
    " but then the backup file must remain
    set nobackup writebackup backupdir=. backupskip=
    let contents = ["line one", "line two"]
!   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,108 ****
    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
--- 100,105 ----
***************
*** 154,162 ****
  
  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(['two'], 'Xtest', 'S')
-   call delete('Xtest')
  endfunc
  
  func Test_writefile_sync_dev_stdout()
--- 151,158 ----
  
  func Test_writefile_sync_arg()
    " This doesn't check if fsync() works, only that the argument is accepted.
!   call writefile(['one'], 'Xtest', 'sD')
    call writefile(['two'], 'Xtest', 'S')
  endfunc
  
  func Test_writefile_sync_dev_stdout()
***************
*** 311,317 ****
    CheckRunVimInTerminal
  
    " First read the file into a buffer
!   call writefile(["Line1", "Line2"], 'Xwfmfile')
    let old_ftime = getftime('Xwfmfile')
    let buf = RunVimInTerminal('Xwfmfile', #{rows : 10})
    call TermWait(buf)
--- 307,313 ----
    CheckRunVimInTerminal
  
    " First read the file into a buffer
!   call writefile(["Line1", "Line2"], 'Xwfmfile', 'D')
    let old_ftime = getftime('Xwfmfile')
    let buf = RunVimInTerminal('Xwfmfile', #{rows : 10})
    call TermWait(buf)
***************
*** 347,353 ****
  
    " clean up
    call StopVimInTerminal(buf)
-   call delete('Xwfmfile')
  endfunc
  
  " Test for an autocmd unloading a buffer during a write command
--- 343,348 ----
***************
*** 417,423 ****
  
  " Test for writing to a readonly file
  func Test_write_readonly()
!   call writefile([], 'Xwrofile')
    call setfperm('Xwrofile', "r--------")
    edit Xwrofile
    set noreadonly backupskip=
--- 412,418 ----
  
  " Test for writing to a readonly file
  func Test_write_readonly()
!   call writefile([], 'Xwrofile', 'D')
    call setfperm('Xwrofile', "r--------")
    edit Xwrofile
    set noreadonly backupskip=
***************
*** 442,454 ****
    set autowriteall&
  
    set backupskip&
-   call delete('Xwrofile')
    %bw!
  endfunc
  
  " Test for 'patchmode'
  func Test_patchmode()
!   call writefile(['one'], 'Xpafile')
    set patchmode=.orig nobackup backupskip= writebackup
    new Xpafile
    call setline(1, 'two')
--- 437,448 ----
    set autowriteall&
  
    set backupskip&
    %bw!
  endfunc
  
  " Test for 'patchmode'
  func Test_patchmode()
!   call writefile(['one'], 'Xpafile', 'D')
    set patchmode=.orig nobackup backupskip= writebackup
    new Xpafile
    call setline(1, 'two')
***************
*** 473,479 ****
    call assert_equal([], readfile('Xpafile.orig'))
  
    set patchmode& backup& backupskip& writebackup&
-   call delete('Xpafile')
    call delete('Xpafile.orig')
  endfunc
  
--- 467,472 ----
***************
*** 485,491 ****
    " Root can do it too.
    CheckNotRoot
  
!   call mkdir('Xrodir/')
    call writefile(['one'], 'Xrodir/Xfile1')
    call setfperm('Xrodir', 'r-xr--r--')
    " try to create a new file in the directory
--- 478,484 ----
    " Root can do it too.
    CheckNotRoot
  
!   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,504 ****
    set patchmode=.orig
    call assert_fails('write', 'E509:')
    call setfperm('Xrodir', 'rwxr--r--')
-   call delete('Xrodir', 'rf')
    set backupdir& backupskip& patchmode&
  endfunc
  
--- 491,496 ----
***************
*** 521,527 ****
      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')
    edit Xwfefile
  
    " write tests:
--- 513,519 ----
      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', 'D')
    edit Xwfefile
  
    " write tests:
***************
*** 614,620 ****
    END
    call assert_equal(expected, readfile('Xwfetest'))
  
-   call delete('Xwfefile')
    call delete('Xwfetest')
    call delete('Xutf8')
    call delete('Xcp1251')
--- 606,611 ----
***************
*** 641,647 ****
    set cpoptions+=S
  
    " Check that editing a latin1 file doesn't see a BOM
!   call writefile(["\xFE\xFElatin-1"], 'Xrwtest1')
    edit Xrwtest1
    call assert_equal('latin1', &fileencoding)
    call assert_equal(0, &bomb)
--- 632,638 ----
    set cpoptions+=S
  
    " Check that editing a latin1 file doesn't see a BOM
!   call writefile(["\xFE\xFElatin-1"], 'Xrwtest1', 'D')
    edit Xrwtest1
    call assert_equal('latin1', &fileencoding)
    call assert_equal(0, &bomb)
***************
*** 746,752 ****
  
    set cpoptions-=S
    let &fileencoding = save_fileencoding
-   call delete('Xrwtest1')
    call delete('Xrwfile2')
    call delete('Xrwtest3')
    %bw!
--- 737,742 ----
***************
*** 754,760 ****
  
  func Test_read_write_bin()
    " write file missing EOL
!   call writefile(['noeol'], "XNoEolSetEol", 'bS')
    call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B'))
  
    " when file is read 'eol' is off
--- 744,750 ----
  
  func Test_read_write_bin()
    " write file missing EOL
!   call writefile(['noeol'], "XNoEolSetEol", 'bSD')
    call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B'))
  
    " when file is read 'eol' is off
***************
*** 767,773 ****
    w
    call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
  
-   call delete('XNoEolSetEol')
    set ff& fixeol&
    bwipe! XNoEolSetEol
  endfunc
--- 757,762 ----
***************
*** 899,905 ****
    call mkdir('Xbackup')
    let save_backupdir = &backupdir
    set backupdir=.,./Xbackup
!   call writefile(['1111'], 'Xwbsfile')
    silent !ln -s Xwbsfile Xwbsfile.bak
  
    new Xwbsfile
--- 888,894 ----
    call mkdir('Xbackup')
    let save_backupdir = &backupdir
    set backupdir=.,./Xbackup
!   call writefile(['1111'], 'Xwbsfile', 'D')
    silent !ln -s Xwbsfile Xwbsfile.bak
  
    new Xwbsfile
***************
*** 915,921 ****
    set backup& backupcopy& backupext&
    %bw
  
-   call delete('Xwbsfile')
    call delete('Xwbsfile.bak')
    call delete('Xbackup', 'rf')
    let &backupdir = save_backupdir
--- 904,909 ----
***************
*** 924,930 ****
  " 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')
    new Xwbfile1
    write ++bin Xwbfile2
    write ++nobin Xwbfile3
--- 912,918 ----
  " Test for ':write ++bin' and ':write ++nobin'
  func Test_write_binary_file()
    " create a file without an eol/eof character
!   call writefile(0z616161, 'Xwbfile1', 'bD')
    new Xwbfile1
    write ++bin Xwbfile2
    write ++nobin Xwbfile3
***************
*** 934,940 ****
    else
      call assert_equal(0z6161610A, readblob('Xwbfile3'))
    endif
-   call delete('Xwbfile1')
    call delete('Xwbfile2')
    call delete('Xwbfile3')
  endfunc
--- 922,927 ----
*** ../vim-9.0.0768/src/testdir/test_xxd.vim    2022-06-29 20:24:46.110172347 
+0100
--- src/testdir/test_xxd.vim    2022-10-15 21:57:24.770867190 +0100
***************
*** 274,281 ****
  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')
    exe cmd1
    exe cmd2
    call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42                 
   ::AA::::BB'], readfile('Xxxdout'))
--- 274,281 ----
  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', '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,313 ****
    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
  
--- 306,311 ----
***************
*** 369,375 ****
  " -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')
    for cols in ['-c0', '-c 0', '-cols 0']
      for fmt in ['', '-b', '-e', '-i']
        exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1'
--- 367,373 ----
  " -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', 'D')
    for cols in ['-c0', '-c 0', '-cols 0']
      for fmt in ['', '-b', '-e', '-i']
        exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1'
***************
*** 377,383 ****
        call assert_equalfile('Xxdout1', 'Xxdout2')
      endfor
    endfor
-   call delete('Xxdin')
    call delete('Xxdout1')
    call delete('Xxdout2')
  endfunc
--- 375,380 ----
***************
*** 391,397 ****
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"],
!         \ 'Xxdin')
    for cols in ['-c0', '-c 0', '-cols 0']
      exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin'
      " output seems to start in line 2
--- 388,394 ----
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"],
!         \ '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,408 ****
      " 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
--- 399,404 ----
*** ../vim-9.0.0768/src/version.c       2022-10-15 21:35:51.195403809 +0100
--- src/version.c       2022-10-15 21:58:44.906797150 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     769,
  /**/

-- 
BRIDGEKEEPER: What is your favorite colour?
LAUNCELOT:    Blue.
BRIDGEKEEPER: Right.  Off you go.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221015210638.41BF21C05ED%40moolenaar.net.

Raspunde prin e-mail lui