changeset 30582:72245f9c9405 v9.0.0626

patch 9.0.0626: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/b152b6a40f729ed81a25d2fa541a4e73e201bec4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 29 21:37:33 2022 +0100 patch 9.0.0626: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Sep 2022 22:45:04 +0200
parents 2e1ec75a7766
children fc88f4597670
files src/testdir/test_mapping.vim src/testdir/test_match.vim src/testdir/test_matchadd_conceal.vim src/testdir/test_memory_usage.vim src/testdir/test_messages.vim src/testdir/test_mksession.vim src/testdir/test_modeline.vim src/testdir/test_netbeans.vim src/testdir/test_normal.vim src/testdir/test_number.vim src/version.c
diffstat 11 files changed, 52 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -420,7 +420,7 @@ func Test_error_in_map_expr()
   nmap <expr> ! Func()
   set updatetime=50
   [CODE]
-  call writefile(lines, 'Xtest.vim')
+  call writefile(lines, 'Xtest.vim', 'D')
 
   let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
   let job = term_getjob(buf)
@@ -439,7 +439,6 @@ func Test_error_in_map_expr()
     call assert_equal('', job_info(job).termsig)
   endif
 
-  call delete('Xtest.vim')
   exe buf .. 'bwipe!'
 endfunc
 
@@ -565,14 +564,13 @@ func Test_expr_map_restore_cursor()
       endfunc
       set stl=%{Status()}
   END
-  call writefile(lines, 'XtestExprMap')
+  call writefile(lines, 'XtestExprMap', 'D')
   let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
   call term_sendkeys(buf, "\<C-B>")
   call VerifyScreenDump(buf, 'Test_map_expr_1', {})
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestExprMap')
 endfunc
 
 func Test_map_listing()
@@ -581,14 +579,13 @@ func Test_map_listing()
   let lines =<< trim END
       nmap a b
   END
-  call writefile(lines, 'XtestMapList')
+  call writefile(lines, 'XtestMapList', 'D')
   let buf = RunVimInTerminal('-S XtestMapList', #{rows: 6})
   call term_sendkeys(buf, ":                      nmap a\<CR>")
   call VerifyScreenDump(buf, 'Test_map_list_1', {})
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestMapList')
 endfunc
 
 func Test_expr_map_error()
@@ -605,7 +602,7 @@ func Test_expr_map_error()
 
       call test_override('ui_delay', 10)
   END
-  call writefile(lines, 'XtestExprMap')
+  call writefile(lines, 'XtestExprMap', 'D')
   let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
   call term_sendkeys(buf, "\<F2>")
   call TermWait(buf)
@@ -619,7 +616,6 @@ func Test_expr_map_error()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestExprMap')
 endfunc
 
 " Test for mapping errors
@@ -1081,11 +1077,10 @@ func Test_map_cmdkey()
       let g:x = 32
     endfunc
   END
-  call writefile(lines, 'Xscript')
+  call writefile(lines, 'Xscript', 'D')
   source Xscript
   call feedkeys("\<F2>", 'xt')
   call assert_equal(32, g:x)
-  call delete('Xscript')
 
   unmap <F3>
   unmap! <F3>
@@ -1530,7 +1525,7 @@ func Test_map_script_cmd_survives_unmap(
 endfunc
 
 func Test_map_script_cmd_redo()
-  call mkdir('Xmapcmd')
+  call mkdir('Xmapcmd', 'R')
   let lines =<< trim END
       vim9script
       import autoload './script.vim'
@@ -1554,7 +1549,6 @@ func Test_map_script_cmd_redo()
 
   ounmap <F3>
   nunmap j
-  call delete('Xmapcmd', 'rf')
   bwipe!
 endfunc
 
@@ -1724,7 +1718,7 @@ func Test_map_after_timed_out_nop()
     inoremap ab TEST
     inoremap a <Nop>
   END
-  call writefile(lines, 'Xtest_map_after_timed_out_nop')
+  call writefile(lines, 'Xtest_map_after_timed_out_nop', 'D')
   let buf = RunVimInTerminal('-S Xtest_map_after_timed_out_nop', #{rows: 6})
 
   " Enter Insert mode
@@ -1741,7 +1735,6 @@ func Test_map_after_timed_out_nop()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('Xtest_map_after_timed_out_nop')
 endfunc
 
 func Test_using_past_typeahead()
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -372,12 +372,11 @@ func Test_match_in_linebreak()
     call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
     call matchaddpos('ErrorMsg', [[1, 51]])
   END
-  call writefile(lines, 'XscriptMatchLinebreak')
+  call writefile(lines, 'XscriptMatchLinebreak', 'D')
   let buf = RunVimInTerminal('-S XscriptMatchLinebreak', #{rows: 10})
   call VerifyScreenDump(buf, 'Test_match_linebreak', {})
 
   call StopVimInTerminal(buf)
-  call delete('XscriptMatchLinebreak')
 endfunc
 
 func Test_match_with_incsearch()
@@ -388,7 +387,7 @@ func Test_match_with_incsearch()
     call setline(1, range(20))
     call matchaddpos('ErrorMsg', [3])
   END
-  call writefile(lines, 'XmatchWithIncsearch')
+  call writefile(lines, 'XmatchWithIncsearch', 'D')
   let buf = RunVimInTerminal('-S XmatchWithIncsearch', #{rows: 6})
   call VerifyScreenDump(buf, 'Test_match_with_incsearch_1', {})
 
@@ -397,7 +396,6 @@ func Test_match_with_incsearch()
 
   call term_sendkeys(buf, "\<CR>")
   call StopVimInTerminal(buf)
-  call delete('XmatchWithIncsearch')
 endfunc
 
 " Test for deleting matches outside of the screen redraw top/bottom lines
@@ -428,12 +426,11 @@ func Test_match_tab_with_linebreak()
     call setline(1, "\tix")
     call matchadd('ErrorMsg', '\t')
   END
-  call writefile(lines, 'XscriptMatchTabLinebreak')
+  call writefile(lines, 'XscriptMatchTabLinebreak', 'D')
   let buf = RunVimInTerminal('-S XscriptMatchTabLinebreak', #{rows: 10})
   call VerifyScreenDump(buf, 'Test_match_tab_linebreak', {})
 
   call StopVimInTerminal(buf)
-  call delete('XscriptMatchTabLinebreak')
 endfunc
 
 
--- a/src/testdir/test_matchadd_conceal.vim
+++ b/src/testdir/test_matchadd_conceal.vim
@@ -374,7 +374,7 @@ func Test_cursor_column_in_concealed_lin
     normal gg
     "==expr==
   END
-  call writefile(lines, 'Xcolesearch')
+  call writefile(lines, 'Xcolesearch', 'D')
   let buf = RunVimInTerminal('Xcolesearch', {})
   call TermWait(buf, 50)
 
@@ -394,7 +394,6 @@ func Test_cursor_column_in_concealed_lin
   call assert_equal(2, term_getcursor(buf)[1])
 
   call StopVimInTerminal(buf)
-  call delete('Xcolesearch')
 endfunc
 
 func Test_cursor_column_in_concealed_line_after_leftcol_change()
@@ -406,7 +405,7 @@ func Test_cursor_column_in_concealed_lin
     call matchadd('Conceal', '-')
     set nowrap ss=0 cole=3 cocu=n
   END
-  call writefile(lines, 'Xcurs-columns')
+  call writefile(lines, 'Xcurs-columns', 'D')
   let buf = RunVimInTerminal('-S Xcurs-columns', {})
 
   " Go to the end of the line (3 columns beyond the end of the screen).
@@ -422,7 +421,6 @@ func Test_cursor_column_in_concealed_lin
   call assert_equal(1, term_getcursor(buf)[1])
 
   call StopVimInTerminal(buf)
-  call delete('Xcurs-columns')
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_memory_usage.vim
+++ b/src/testdir/test_memory_usage.vim
@@ -92,7 +92,7 @@ func Test_memory_func_capture_vargs()
           call s:f(0)
         endfor
   END
-  call writefile(lines, testfile)
+  call writefile(lines, testfile, 'D')
 
   let vim = s:vim_new()
   call vim.start('--clean', '-c', 'set noswapfile', testfile)
@@ -114,7 +114,6 @@ func Test_memory_func_capture_vargs()
   call assert_inrange(lower, upper, after.max)
 
   call vim.stop()
-  call delete(testfile)
 endfunc
 
 func Test_memory_func_capture_lvars()
@@ -130,7 +129,7 @@ func Test_memory_func_capture_lvars()
           call s:f()
         endfor
   END
-  call writefile(lines, testfile)
+  call writefile(lines, testfile, 'D')
 
   let vim = s:vim_new()
   call vim.start('--clean', '-c', 'set noswapfile', testfile)
@@ -161,7 +160,6 @@ func Test_memory_func_capture_lvars()
   call assert_inrange(lower, upper, last)
 
   call vim.stop()
-  call delete(testfile)
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -103,7 +103,7 @@ func Test_mode_message_at_leaving_insert
         set statusline=%!StatusLine()
         set laststatus=2
   END
-  call writefile(lines, testfile)
+  call writefile(lines, testfile, 'D')
 
   let rows = 10
   let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
@@ -117,8 +117,8 @@ func Test_mode_message_at_leaving_insert
 
   call term_sendkeys(buf, ":qall!\<CR>")
   call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
+
   exe buf . 'bwipe!'
-  call delete(testfile)
 endfunc
 
 func Test_mode_message_at_leaving_insert_with_esc_mapped()
@@ -131,7 +131,7 @@ func Test_mode_message_at_leaving_insert
         set laststatus=2
         inoremap <Esc> <Esc>00
   END
-  call writefile(lines, testfile)
+  call writefile(lines, testfile, 'D')
 
   let rows = 10
   let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
@@ -145,8 +145,8 @@ func Test_mode_message_at_leaving_insert
 
   call term_sendkeys(buf, ":qall!\<CR>")
   call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
+
   exe buf . 'bwipe!'
-  call delete(testfile)
 endfunc
 
 func Test_echospace()
@@ -462,7 +462,7 @@ func Test_fileinfo_after_echo()
     autocmd CursorHold * buf b.txt | w | echo "'b' written"
   END
 
-  call writefile(content, 'Xtest_fileinfo_after_echo')
+  call writefile(content, 'Xtest_fileinfo_after_echo', 'D')
   let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6})
   call term_sendkeys(buf, ":set updatetime=50\<CR>")
   call term_sendkeys(buf, "0$")
@@ -472,7 +472,6 @@ func Test_fileinfo_after_echo()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('Xtest_fileinfo_after_echo')
   call delete('b.txt')
 endfunc
 
@@ -513,7 +512,7 @@ func Test_echowindow()
         echo 'three'
       enddef
   END
-  call writefile(lines, 'XtestEchowindow')
+  call writefile(lines, 'XtestEchowindow', 'D')
   let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
   call VerifyScreenDump(buf, 'Test_echowindow_1', {})
 
@@ -542,7 +541,6 @@ func Test_echowindow()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestEchowindow')
 endfunc
 
 " messages window should not be used while evaluating the :echowin argument
@@ -556,13 +554,12 @@ func Test_echowin_eval()
       endfunc
       echowindow ShowMessage()
   END
-  call writefile(lines, 'XtestEchowindow')
+  call writefile(lines, 'XtestEchowindow', 'D')
   let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
   call VerifyScreenDump(buf, 'Test_echowin_eval', {})
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestEchowindow')
 endfunc
 
 " messages window should not be used for showing the mode
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -1098,14 +1098,13 @@ func Test_mksession_shortmess_with_A()
   bwipe!
 
   " Recreate the swap file to pretend the file is being edited
-  call writefile(cont, fname)
+  call writefile(cont, fname, 'D')
   set shortmess+=A
   source Xtestsession
 
   set shortmess&
   set sessionoptions&
   call delete('Xtestsession')
-  call delete(fname)
 endfunc
 
 " Test for mksession with 'compatible' option
@@ -1235,7 +1234,7 @@ endfunc
 
 " Test for creating views with manual folds
 func Test_mkview_manual_fold()
-  call writefile(range(1,10), 'Xmkvfile')
+  call writefile(range(1,10), 'Xmkvfile', 'D')
   new Xmkvfile
   " create recursive folds
   5,6fold
@@ -1259,7 +1258,6 @@ func Test_mkview_manual_fold()
   source Xview
   call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4),
         \ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
-  call delete('Xmkvfile')
   call delete('Xview')
   bw!
 endfunc
--- a/src/testdir/test_modeline.vim
+++ b/src/testdir/test_modeline.vim
@@ -4,7 +4,7 @@ source check.vim
 
 func Test_modeline_invalid()
   " This was reading allocated memory in the past.
-  call writefile(['vi:0', 'nothing'], 'Xmodeline')
+  call writefile(['vi:0', 'nothing'], 'Xmodeline', 'D')
   let modeline = &modeline
   set modeline
   call assert_fails('split Xmodeline', 'E518:')
@@ -29,11 +29,10 @@ func Test_modeline_invalid()
 
   let &modeline = modeline
   bwipe!
-  call delete('Xmodeline')
 endfunc
 
 func Test_modeline_filetype()
-  call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype')
+  call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype', 'D')
   let modeline = &modeline
   set modeline
   filetype plugin on
@@ -43,13 +42,12 @@ func Test_modeline_filetype()
   call assert_equal("ccomplete#Complete", &ofu)
 
   bwipe!
-  call delete('Xmodeline_filetype')
   let &modeline = modeline
   filetype plugin off
 endfunc
 
 func Test_modeline_syntax()
-  call writefile(['vim: set syn=c :', 'nothing'], 'Xmodeline_syntax')
+  call writefile(['vim: set syn=c :', 'nothing'], 'Xmodeline_syntax', 'D')
   let modeline = &modeline
   set modeline
   syntax enable
@@ -58,14 +56,13 @@ func Test_modeline_syntax()
   call assert_equal("c", b:current_syntax)
 
   bwipe!
-  call delete('Xmodeline_syntax')
   let &modeline = modeline
   syntax off
 endfunc
 
 func Test_modeline_keymap()
   CheckFeature keymap
-  call writefile(['vim: set keymap=greek :', 'nothing'], 'Xmodeline_keymap')
+  call writefile(['vim: set keymap=greek :', 'nothing'], 'Xmodeline_keymap', 'D')
   let modeline = &modeline
   set modeline
   split Xmodeline_keymap
@@ -73,7 +70,6 @@ func Test_modeline_keymap()
   call assert_match('greek\|grk', b:keymap_name)
 
   bwipe!
-  call delete('Xmodeline_keymap')
   let &modeline = modeline
   set keymap= iminsert=0 imsearch=-1
 endfunc
@@ -83,7 +79,7 @@ func Test_modeline_version()
   set modeline
 
   " Test with vim:{vers}: (version {vers} or later).
-  call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version')
+  call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version', 'D')
   edit Xmodeline_version
   call assert_equal(2, &ts)
   bwipe!
@@ -147,14 +143,13 @@ func Test_modeline_version()
   bwipe!
 
   let &modeline = modeline
-  call delete('Xmodeline_version')
 endfunc
 
 func Test_modeline_colon()
   let modeline = &modeline
   set modeline
 
-  call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon')
+  call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon', 'D')
   edit Xmodeline_colon
 
   " backlash colon should become colon.
@@ -166,13 +161,12 @@ func Test_modeline_colon()
   call assert_equal(8, &sw)
 
   let &modeline = modeline
-  call delete('Xmodeline_colon')
 endfunc
 
 func s:modeline_fails(what, text, error)
   call CheckOption(a:what)
   let fname = "Xmodeline_fails_" . a:what
-  call writefile(['vim: set ' . a:text . ' :', 'nothing'], fname)
+  call writefile(['vim: set ' . a:text . ' :', 'nothing'], fname, 'D')
   let modeline = &modeline
   set modeline
   filetype plugin on
@@ -182,7 +176,6 @@ func s:modeline_fails(what, text, error)
   call assert_equal("", &syntax)
 
   bwipe!
-  call delete(fname)
   let &modeline = modeline
   filetype plugin off
   syntax off
@@ -292,7 +285,7 @@ func Test_modeline_setoption_verbose()
   7 seven
   8 eight
   END
-  call writefile(lines, 'Xmodeline')
+  call writefile(lines, 'Xmodeline', 'D')
   edit Xmodeline
   let info = split(execute('verbose set tabstop?'), "\n")
   call assert_match('^\s*Last set from modeline line 1$', info[-1])
@@ -331,7 +324,6 @@ func Test_modeline_setoption_verbose()
   bwipe!
 
   let &modeline = modeline
-  call delete('Xmodeline')
 endfunc
 
 " Test for the 'modeline' default value in compatible and non-compatible modes
@@ -350,22 +342,20 @@ endfunc
 
 " Some options cannot be set from the modeline when 'diff' option is set
 func Test_modeline_diff_buffer()
-  call writefile(['vim: diff foldmethod=marker wrap'], 'Xmdifile')
+  call writefile(['vim: diff foldmethod=marker wrap'], 'Xmdifile', 'D')
   set foldmethod& nowrap
   new Xmdifile
   call assert_equal('manual', &foldmethod)
   call assert_false(&wrap)
   set wrap&
-  call delete('Xmdifile')
   bw
 endfunc
 
 func Test_modeline_disable()
   set modeline
-  call writefile(['vim: sw=2', 'vim: nomodeline', 'vim: sw=3'], 'Xmodeline_disable')
+  call writefile(['vim: sw=2', 'vim: nomodeline', 'vim: sw=3'], 'Xmodeline_disable', 'D')
   edit Xmodeline_disable
   call assert_equal(2, &sw)
-  call delete('Xmodeline_disable')
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_netbeans.vim
+++ b/src/testdir/test_netbeans.vim
@@ -41,8 +41,7 @@ func ReadXnetbeans()
 endfunc
 
 func Nb_basic(port)
-  call delete("Xnetbeans")
-  call writefile([], "Xnetbeans")
+  call writefile([], "Xnetbeans", 'D')
 
   " Last line number in the Xnetbeans file. Used to verify the result of the
   " communication with the netbeans server
@@ -79,7 +78,7 @@ func Nb_basic(port)
   sleep 1m
 
   " getCursor test
-  call writefile(['foo bar', 'foo bar', 'foo bar'], 'Xfile1')
+  call writefile(['foo bar', 'foo bar', 'foo bar'], 'Xfile1', 'D')
   split Xfile1
   call cursor(3, 4)
   sleep 10m
@@ -272,7 +271,7 @@ func Nb_basic(port)
   let g:last += 4
 
   " editFile test
-  call writefile(['foo bar1', 'foo bar2', 'foo bar3'], 'Xfile3')
+  call writefile(['foo bar1', 'foo bar2', 'foo bar3'], 'Xfile3', 'D')
   call appendbufline(cmdbufnr, '$', 'editFile_Test')
   call WaitFor('len(ReadXnetbeans()) >= (g:last + 4)')
   let l = ReadXnetbeans()
@@ -838,9 +837,6 @@ func Nb_basic(port)
   call sign_unplace('*')
   call sign_undefine()
 
-  call delete("Xnetbeans")
-  call delete('Xfile1')
-  call delete('Xfile3')
   call delete('Xfile4')
 endfunc
 
@@ -851,10 +847,10 @@ endfunc
 
 func Nb_file_auth(port)
   call delete("Xnetbeans")
-  call writefile([], "Xnetbeans")
+  call writefile([], "Xnetbeans", 'D')
 
   call assert_fails('nbstart =notexist', 'E660:')
-  call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth')
+  call writefile(['host=localhost', 'port=' . a:port, 'auth=bunny'], 'Xnbauth', 'D')
   if has('unix')
     call setfperm('Xnbauth', "rw-r--r--")
     call assert_fails('nbstart =Xnbauth', 'E668:')
@@ -871,7 +867,6 @@ func Nb_file_auth(port)
   call assert_equal('0:startupDone=0', lines[2])
 
   call delete("Xnbauth")
-  call delete("Xnetbeans")
 endfunc
 
 func Test_nb_file_auth()
@@ -882,7 +877,7 @@ endfunc
 " Test for quitting Vim with an open netbeans connection
 func Nb_quit_with_conn(port)
   call delete("Xnetbeans")
-  call writefile([], "Xnetbeans")
+  call writefile([], "Xnetbeans", 'D')
   let after =<< trim END
     source shared.vim
     set cpo&vim
@@ -922,7 +917,6 @@ func Nb_quit_with_conn(port)
     call assert_equal('1:killed=16', l[-2])
     call assert_equal('0:disconnect=16', l[-1])
   endif
-  call delete('Xnetbeans')
 endfunc
 
 func Test_nb_quit_with_conn()
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -299,7 +299,7 @@ func Test_normal06_formatprg()
   CheckNotMSWindows
 
   " uses sed to number non-empty lines
-  call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/    /', '}'''], 'Xsed_format.sh')
+  call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/    /', '}'''], 'Xsed_format.sh', 'D')
   call system('chmod +x ./Xsed_format.sh')
   let text = ['a', '', 'c', '', ' ', 'd', 'e']
   let expected = ['1    a', '', '3    c', '', '5     ', '6    d', '7    e']
@@ -330,7 +330,6 @@ func Test_normal06_formatprg()
   " clean up
   set formatprg=
   setlocal formatprg=
-  call delete('Xsed_format.sh')
 endfunc
 
 func Test_normal07_internalfmt()
@@ -702,11 +701,10 @@ func Test_opfunc_callback()
     call writefile([execute('messages')], 'Xtest.out')
     qall
   END
-  call writefile(cleanup, 'Xverify.vim')
+  call writefile(cleanup, 'Xverify.vim', 'D')
   call RunVim([], [], "-c \"set opfunc=s:abc\" -S Xverify.vim")
   call assert_match('E81: Using <SID> not in a', readfile('Xtest.out')[0])
   call delete('Xtest.out')
-  call delete('Xverify.vim')
 
   " cleanup
   set opfunc&
@@ -1292,11 +1290,10 @@ func Test_scroll_in_ex_mode()
       call writefile(['done'], 'Xdone')
       qa!
   END
-  call writefile(lines, 'Xscript')
+  call writefile(lines, 'Xscript', 'D')
   call assert_equal(1, RunVim([], [], '--clean -X -Z -e -s -S Xscript'))
   call assert_equal(['done'], readfile('Xdone'))
 
-  call delete('Xscript')
   call delete('Xdone')
 endfunc
 
@@ -1709,16 +1706,14 @@ endfunc
 func Test_normal20_exmode()
   " Reading from redirected file doesn't work on MS-Windows
   CheckNotMSWindows
-  call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script')
-  call writefile(['1', '2'], 'Xn20file')
+  call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script', 'D')
+  call writefile(['1', '2'], 'Xn20file', 'D')
   call system(GetVimCommand() .. ' -e -s < Xn20script Xn20file')
-  let a=readfile('Xn20file2')
+  let a = readfile('Xn20file2')
   call assert_equal(['1', 'foo', 'bar', '2'], a)
 
   " clean up
-  for file in ['Xn20file', 'Xn20file2', 'Xn20script']
-    call delete(file)
-  endfor
+  call delete('Xn20file2')
   bw!
 endfunc
 
@@ -1758,7 +1753,7 @@ func Test_normal22_zet()
   " Test for ZZ
   " let shell = &shell
   " let &shell = 'sh'
-  call writefile(['1', '2'], 'Xn22file')
+  call writefile(['1', '2'], 'Xn22file', 'D')
   let args = ' -N -i NONE --noplugins -X --not-a-term'
   call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xn22file')
   let a = readfile('Xn22file')
@@ -1773,9 +1768,6 @@ func Test_normal22_zet()
   call assert_beeps('normal! ZW')
 
   " clean up
-  for file in ['Xn22file']
-    call delete(file)
-  endfor
   " let &shell = shell
 endfunc
 
@@ -3141,7 +3133,7 @@ func Test_normal51_FileChangedRO()
   CheckFeature autocmd
   " Don't sleep after the warning message.
   call test_settime(1)
-  call writefile(['foo'], 'Xreadonly.log')
+  call writefile(['foo'], 'Xreadonly.log', 'D')
   new Xreadonly.log
   setl ro
   au FileChangedRO <buffer> :call feedkeys("\<c-^>", 'tix')
@@ -3152,7 +3144,6 @@ func Test_normal51_FileChangedRO()
   " cleanup
   call test_settime(0)
   bw!
-  call delete("Xreadonly.log")
 endfunc
 
 func Test_normal52_rl()
--- a/src/testdir/test_number.vim
+++ b/src/testdir/test_number.vim
@@ -276,7 +276,7 @@ func Test_relativenumber_colors()
     set number relativenumber
     hi LineNr ctermfg=red
   [CODE]
-  call writefile(lines, 'XTest_relnr')
+  call writefile(lines, 'XTest_relnr', 'D')
 
   " Check that the balloon shows up after a mouse move
   let buf = RunVimInTerminal('-S XTest_relnr', {'rows': 10, 'cols': 50})
@@ -295,7 +295,6 @@ func Test_relativenumber_colors()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_relnr')
 endfunc
 
 func Test_relativenumber_callback()
@@ -313,14 +312,13 @@ func Test_relativenumber_callback()
 
       call timer_start(300, 'Func')
   END
-  call writefile(lines, 'Xrnu_timer')
+  call writefile(lines, 'Xrnu_timer', 'D')
 
   let buf = RunVimInTerminal('-S Xrnu_timer', #{rows: 8})
   call TermWait(buf, 310)
   call VerifyScreenDump(buf, 'Test_relativenumber_callback_1', {})
 
   call StopVimInTerminal(buf)
-  call delete('Xrnu_timer')
 endfunc
 
 " Test for displaying line numbers with 'rightleft'
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    626,
+/**/
     625,
 /**/
     624,