changeset 30164:f7a2de8a4ddc v9.0.0418

patch 9.0.0418: manually deleting temp test files Commit: https://github.com/vim/vim/commit/45bbaef0382c5468d9fac511775bd99ea7bf5b84 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 8 16:39:22 2022 +0100 patch 9.0.0418: manually deleting temp test files Problem: Manually deleting temp test files. Solution: Use the 'D' flag of writefile() and mkdir().
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Sep 2022 17:45:03 +0200
parents ac28d70ac476
children 27820ff1eaf4
files src/testdir/test_cd.vim src/testdir/test_changelist.vim src/testdir/test_channel.vim src/testdir/test_checkpath.vim src/testdir/test_cmdline.vim src/testdir/test_cmdwin.vim src/testdir/test_conceal.vim src/testdir/test_cpoptions.vim src/testdir/test_cscope.vim src/testdir/test_cursorline.vim src/version.c
diffstat 11 files changed, 85 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -58,18 +58,17 @@ func Test_cd_minus()
     call writefile(v:errors, 'Xresult')
     qall!
   [SCRIPT]
-  call writefile(lines, 'Xscript')
+  call writefile(lines, 'Xscript', 'D')
   if RunVim([], [], '--clean -S Xscript')
     call assert_equal([], readfile('Xresult'))
   endif
-  call delete('Xscript')
   call delete('Xresult')
 endfunc
 
 " Test for chdir()
 func Test_chdir_func()
   let topdir = getcwd()
-  call mkdir('Xchdir/y/z', 'p')
+  call mkdir('Xchdir/y/z', 'pR')
 
   " Create a few tabpages and windows with different directories
   new
@@ -110,13 +109,12 @@ func Test_chdir_func()
 
   only | tabonly
   call chdir(topdir)
-  call delete('Xchdir', 'rf')
 endfunc
 
 " Test for changing to the previous directory '-'
 func Test_prev_dir()
   let topdir = getcwd()
-  call mkdir('Xprevdir/a/b/c', 'p')
+  call mkdir('Xprevdir/a/b/c', 'pR')
 
   " Create a few tabpages and windows with different directories
   new | only
@@ -173,7 +171,6 @@ func Test_prev_dir()
 
   only | tabonly
   call chdir(topdir)
-  call delete('Xprevdir', 'rf')
 endfunc
 
 func Test_lcd_split()
@@ -201,22 +198,18 @@ func Test_cd_from_non_existing_dir()
 endfunc
 
 func Test_cd_completion()
-  call mkdir('XComplDir1', 'p')
-  call mkdir('XComplDir2', 'p')
-  call writefile([], 'XComplFile')
+  call mkdir('XComplDir1', 'D')
+  call mkdir('XComplDir2', 'D')
+  call writefile([], 'XComplFile', 'D')
 
   for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir']
     call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx')
     call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:)
   endfor
-
-  call delete('XComplDir1', 'd')
-  call delete('XComplDir2', 'd')
-  call delete('XComplFile')
 endfunc
 
 func Test_cd_unknown_dir()
-  call mkdir('Xa')
+  call mkdir('Xa', 'R')
   cd Xa
   call writefile(['text'], 'Xb.txt')
   edit Xa/Xb.txt
@@ -229,14 +222,13 @@ func Test_cd_unknown_dir()
 
   bwipe!
   exe "bwipe! " .. first_buf
-  call delete('Xa', 'rf')
 endfunc
 
 func Test_getcwd_actual_dir()
   CheckOption autochdir
 
   let startdir = getcwd()
-  call mkdir('Xactual')
+  call mkdir('Xactual', 'R')
   call test_autochdir()
   set autochdir
   edit Xactual/file.txt
@@ -250,7 +242,6 @@ func Test_getcwd_actual_dir()
   set noautochdir
   bwipe!
   call chdir(startdir)
-  call delete('Xactual', 'rf')
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_changelist.vim
+++ b/src/testdir/test_changelist.vim
@@ -64,8 +64,8 @@ func Test_getchangelist()
   call assert_equal([], 10->getchangelist())
   call assert_equal([[], 0], getchangelist())
 
-  call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt')
-  call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt')
+  call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt', 'D')
+  call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt', 'D')
 
   edit Xclistfile1.txt
   let buf_1 = bufnr()
@@ -100,8 +100,6 @@ func Test_getchangelist()
 	      \ getchangelist(buf_2))
 
   bwipe!
-  call delete('Xclistfile1.txt')
-  call delete('Xclistfile2.txt')
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -714,7 +714,7 @@ func Stop_g_job()
 endfunc
 
 func Test_nl_read_file()
-  call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
+  call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput', 'D')
   let g:job = job_start(s:python . " test_channel_pipe.py",
 	\ {'in_io': 'file', 'in_name': 'Xinput'})
   call assert_equal("run", job_status(g:job))
@@ -726,7 +726,6 @@ func Test_nl_read_file()
     call assert_equal("AND this", ch_readraw(handle))
   finally
     call Stop_g_job()
-    call delete('Xinput')
   endtry
   call assert_fails("echo ch_read(test_null_channel(), {'callback' : 'abc'})", 'E475:')
 endfunc
@@ -1161,14 +1160,13 @@ func Test_write_to_buffer_and_scroll()
       endif
       call job_start(cmd, #{out_io: 'buffer', out_name: 'Xscrollbuffer'})
   END
-  call writefile(lines, 'XtestBufferScroll')
+  call writefile(lines, 'XtestBufferScroll', 'D')
   let buf = RunVimInTerminal('-S XtestBufferScroll', #{rows: 10})
   call TermWait(buf, 50)
   call VerifyScreenDump(buf, 'Test_job_buffer_scroll_1', {})
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XtestBufferScroll')
 endfunc
 
 func Test_pipe_null()
@@ -2178,7 +2176,7 @@ endfunc
 func Test_job_tty_in_out()
   CheckUnix
 
-  call writefile(['test'], 'Xtestin')
+  call writefile(['test'], 'Xtestin', 'D')
   let in_opts = [{},
         \ {'in_io': 'null'},
         \ {'in_io': 'file', 'in_name': 'Xtestin'}]
@@ -2220,7 +2218,6 @@ func Test_job_tty_in_out()
     call WaitForAssert({-> assert_equal('dead', job_status(job))})
   endfor
 
-  call delete('Xtestin')
   call delete('Xtestout')
   call delete('Xtesterr')
 endfunc
@@ -2281,9 +2278,9 @@ func Test_zz_ch_log()
   let text = readfile('Xlog')
   call assert_match("hello there", text[1])
   call assert_match("%s%s", text[2])
-  call mkdir("Xchlogdir1")
+  call mkdir("Xchlogdir1", 'D')
   call assert_fails("call ch_logfile('Xchlogdir1')", 'E484:')
-  cal delete("Xchlogdir1", 'd')
+
   call delete('Xlog')
 endfunc
 
--- a/src/testdir/test_checkpath.vim
+++ b/src/testdir/test_checkpath.vim
@@ -2,7 +2,7 @@
 
 " Test for 'include' without \zs or \ze
 func Test_checkpath1()
-  call mkdir("Xcheckdir1/dir2", "p")
+  call mkdir("Xcheckdir1/dir2", "pR")
   call writefile(['#include    "bar.a"'], 'Xcheckdir1/dir2/foo.a')
   call writefile(['#include    "baz.a"'], 'Xcheckdir1/dir2/bar.a')
   call writefile(['#include    "foo.a"'], 'Xcheckdir1/dir2/baz.a')
@@ -23,7 +23,6 @@ func Test_checkpath1()
 
   enew
   call delete("./Xbase.a")
-  call delete("Xcheckdir1", "rf")
   set path&
 endfunc
 
@@ -33,11 +32,11 @@ endfunc
 
 " Test for 'include' with \zs and \ze
 func Test_checkpath2()
-  call mkdir("Xcheckdir2/dir2", "p")
+  call mkdir("Xcheckdir2/dir2", "pR")
   call writefile(['%inc    /bar/'], 'Xcheckdir2/dir2/foo.b')
   call writefile(['%inc    /baz/'], 'Xcheckdir2/dir2/bar.b')
   call writefile(['%inc    /foo/'], 'Xcheckdir2/dir2/baz.b')
-  call writefile(['%inc    /foo/'], 'Xbase.b')
+  call writefile(['%inc    /foo/'], 'Xbase.b', 'D')
 
   let &include='^\s*%inc\s*/\zs[^/]\+\ze'
   let &includeexpr='DotsToSlashes()'
@@ -56,8 +55,6 @@ func Test_checkpath2()
 	      \ '      foo  (Already listed)'], res)
 
   enew
-  call delete("./Xbase.b")
-  call delete("Xcheckdir2", "rf")
   set path&
   set include&
   set includeexpr&
@@ -72,12 +69,12 @@ endfunc
 
 " Test for 'include' with \zs and no \ze
 func Test_checkpath3()
-  call mkdir("Xcheckdir3/dir2", "p")
+  call mkdir("Xcheckdir3/dir2", "pR")
   call writefile(['%inc    bar.c'], 'Xcheckdir3/dir2/foo.c')
   call writefile(['%inc    baz.c'], 'Xcheckdir3/dir2/bar.c')
   call writefile(['%inc    foo.c'], 'Xcheckdir3/dir2/baz.c')
   call writefile(['%inc    foo.c'], 'Xcheckdir3/dir2/FALSE.c')
-  call writefile(['%inc    FALSE.c foo.c'], 'Xbase.c')
+  call writefile(['%inc    FALSE.c foo.c'], 'Xbase.c', 'D')
 
   let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
   let &includeexpr='StripNewlineChar()'
@@ -96,8 +93,6 @@ func Test_checkpath3()
 	      \ '      foo.c  (Already listed)'], res)
 
   enew
-  call delete("./Xbase.c")
-  call delete("Xcheckdir3", "rf")
   set path&
   set include&
   set includeexpr&
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -20,14 +20,13 @@ func TearDown()
 endfunc
 
 func Test_complete_tab()
-  call writefile(['testfile'], 'Xtestfile')
+  call writefile(['testfile'], 'Xtestfile', 'D')
   call feedkeys(":e Xtest\t\r", "tx")
   call assert_equal('testfile', getline(1))
 
   " Pressing <Tab> after '%' completes the current file, also on MS-Windows
   call feedkeys(":e %\t\r", "tx")
   call assert_equal('e Xtestfile', @:)
-  call delete('Xtestfile')
 endfunc
 
 func Test_complete_list()
@@ -42,7 +41,7 @@ func Test_complete_list()
 
   " Test for displaying the tail of the completion matches
   set wildmode=longest,full
-  call mkdir('Xtest')
+  call mkdir('Xtest', 'R')
   call writefile([], 'Xtest/a.c')
   call writefile([], 'Xtest/a.h')
   let g:Sline = ''
@@ -78,12 +77,11 @@ func Test_complete_list()
   call assert_equal(':e Xtes[/', g:Sline)
   call assert_equal('"e Xtes[/', @:)
 
-  call delete('Xtest', 'rf')
   set wildmode&
 endfunc
 
 func Test_complete_wildmenu()
-  call mkdir('Xwilddir1/Xdir2', 'p')
+  call mkdir('Xwilddir1/Xdir2', 'pR')
   call writefile(['testfile1'], 'Xwilddir1/Xtestfile1')
   call writefile(['testfile2'], 'Xwilddir1/Xtestfile2')
   call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3')
@@ -162,7 +160,6 @@ func Test_complete_wildmenu()
 
   " cleanup
   %bwipe
-  call delete('Xwilddir1', 'rf')
   set nowildmenu
 endfunc
 
@@ -172,7 +169,7 @@ func Test_wildmenu_screendump()
   let lines =<< trim [SCRIPT]
     set wildmenu hlsearch
   [SCRIPT]
-  call writefile(lines, 'XTest_wildmenu')
+  call writefile(lines, 'XTest_wildmenu', 'D')
 
   let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8})
   call term_sendkeys(buf, ":vim\<Tab>")
@@ -190,7 +187,6 @@ func Test_wildmenu_screendump()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_wildmenu')
 endfunc
 
 func Test_redraw_in_autocmd()
@@ -200,7 +196,7 @@ func Test_redraw_in_autocmd()
       set cmdheight=2
       autocmd CmdlineChanged * redraw
   END
-  call writefile(lines, 'XTest_redraw')
+  call writefile(lines, 'XTest_redraw', 'D')
 
   let buf = RunVimInTerminal('-S XTest_redraw', {'rows': 8})
   call term_sendkeys(buf, ":for i in range(3)\<CR>")
@@ -212,7 +208,6 @@ func Test_redraw_in_autocmd()
   " clean up
   call term_sendkeys(buf, "\<CR>")
   call StopVimInTerminal(buf)
-  call delete('XTest_redraw')
 endfunc
 
 func Test_changing_cmdheight()
@@ -221,7 +216,7 @@ func Test_changing_cmdheight()
   let lines =<< trim END
       set cmdheight=1 laststatus=2
   END
-  call writefile(lines, 'XTest_cmdheight')
+  call writefile(lines, 'XTest_cmdheight', 'D')
 
   let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8})
   call term_sendkeys(buf, ":resize -3\<CR>")
@@ -246,7 +241,6 @@ func Test_changing_cmdheight()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_cmdheight')
 endfunc
 
 func Test_map_completion()
@@ -455,10 +449,9 @@ func Test_getcompletion()
   call assert_true(index(l, 'runtest.vim') < 0)
   set wildignore&
   " Directory name with space character
-  call mkdir('Xdir with space')
+  call mkdir('Xdir with space', 'D')
   call assert_equal(['Xdir with space/'], getcompletion('Xdir\ w', 'shellcmd'))
   call assert_equal(['./Xdir with space/'], getcompletion('./Xdir', 'shellcmd'))
-  call delete('Xdir with space', 'd')
 
   let l = getcompletion('ha', 'filetype')
   call assert_true(index(l, 'hamster') >= 0)
@@ -581,14 +574,13 @@ func Test_getcompletion()
   endif
 
   set tags=Xtags
-  call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags')
+  call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags', 'D')
 
   for name in names
     let matchcount = len(getcompletion('', name))
     call assert_true(matchcount >= 0, 'No matches for ' . name)
   endfor
 
-  call delete('Xtags')
   set tags&
 
   edit a~b
@@ -633,7 +625,7 @@ func Test_complete_autoload_error()
       enddef
       echo this will cause an error
   END
-  call mkdir('Xdir/autoload', 'p')
+  call mkdir('Xdir/autoload', 'pR')
   call writefile(lines, 'Xdir/autoload/script.vim')
   exe 'set rtp+=' .. getcwd() .. '/Xdir'
 
@@ -647,7 +639,6 @@ func Test_complete_autoload_error()
   call v9.CheckScriptFailure(lines, 'E121: Undefined variable: this')
 
   let &rtp = save_rtp
-  call delete('Xdir', 'rf')
 endfunc
 
 func Test_fullcommand()
@@ -698,7 +689,7 @@ endfunc
 func Test_shellcmd_completion()
   let save_path = $PATH
 
-  call mkdir('Xpathdir/Xpathsubdir', 'p')
+  call mkdir('Xpathdir/Xpathsubdir', 'pR')
   call writefile([''], 'Xpathdir/Xfile.exe')
   call setfperm('Xpathdir/Xfile.exe', 'rwx------')
 
@@ -714,17 +705,15 @@ func Test_shellcmd_completion()
   call insert(expected, 'Xfile.exe')
   call assert_equal(expected, actual)
 
-  call delete('Xpathdir', 'rf')
   let $PATH = save_path
 endfunc
 
 func Test_expand_star_star()
-  call mkdir('a/b', 'p')
+  call mkdir('a/b', 'pR')
   call writefile(['asdfasdf'], 'a/b/fileXname')
   call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
   call assert_equal('find a/b/fileXname', @:)
   bwipe!
-  call delete('a', 'rf')
 endfunc
 
 func Test_cmdline_paste()
@@ -832,14 +821,13 @@ func Test_illegal_address1()
 endfunc
 
 func Test_illegal_address2()
-  call writefile(['c', 'x', '  x', '.', '1;y'], 'Xtest.vim')
+  call writefile(['c', 'x', '  x', '.', '1;y'], 'Xtest.vim', 'D')
   new
   source Xtest.vim
   " Trigger calling validate_cursor()
   diffsp Xtest.vim
   quit!
   bwipe!
-  call delete('Xtest.vim')
 endfunc
 
 func Test_mark_from_line_zero()
@@ -1035,14 +1023,13 @@ func Test_cmdline_complete_various()
   call assert_equal("\"sI \<C-A>", @:)
 
   " completion for :write command
-  call mkdir('Xcwdir')
+  call mkdir('Xcwdir', 'R')
   call writefile(['one'], 'Xcwdir/Xfile1')
   let save_cwd = getcwd()
   cd Xcwdir
   call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt')
   call assert_equal("\"w >> Xfile1", @:)
   call chdir(save_cwd)
-  call delete('Xcwdir', 'rf')
 
   " completion for :w ! and :r ! commands
   call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt')
@@ -1125,12 +1112,10 @@ func Test_cmdline_complete_various()
   call assert_equal("\"doautocmd BufNew,BufEnter", @:)
 
   " completion of file name in :doautocmd
-  call writefile([], 'Xvarfile1')
-  call writefile([], 'Xvarfile2')
+  call writefile([], 'Xvarfile1', 'D')
+  call writefile([], 'Xvarfile2', 'D')
   call feedkeys(":doautocmd BufEnter Xvarfi\<C-A>\<C-B>\"\<CR>", 'xt')
   call assert_equal("\"doautocmd BufEnter Xvarfile1 Xvarfile2", @:)
-  call delete('Xvarfile1')
-  call delete('Xvarfile2')
 
   " completion for the :augroup command
   augroup XTest.test
@@ -1272,7 +1257,7 @@ endfunc
 " Test for 'wildignorecase'
 func Test_cmdline_wildignorecase()
   CheckUnix
-  call writefile([], 'XTEST')
+  call writefile([], 'XTEST', 'D')
   set wildignorecase
   call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"e XTEST', @:)
@@ -1282,7 +1267,6 @@ func Test_cmdline_wildignorecase()
   call assert_equal('"e xt', @:)
   call assert_equal('XTEST', g:Sline)
   set wildignorecase&
-  call delete('XTEST')
 endfunc
 
 func Test_cmdline_write_alternatefile()
@@ -1408,9 +1392,9 @@ func Test_verbosefile()
   let log = readfile('Xlog')
   call assert_match("foo\nbar", join(log, "\n"))
   call delete('Xlog')
-  call mkdir('Xdir')
+
+  call mkdir('Xdir', 'D')
   call assert_fails('set verbosefile=Xdir', ['E484:.*Xdir', 'E474:'])
-  call delete('Xdir', 'd')
 endfunc
 
 func Test_verbose_option()
@@ -1421,7 +1405,7 @@ func Test_verbose_option()
     call feedkeys("\r", 't') " for the hit-enter prompt
     set verbose=20
   [SCRIPT]
-  call writefile(lines, 'XTest_verbose')
+  call writefile(lines, 'XTest_verbose', 'D')
 
   let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12})
   call TermWait(buf, 50)
@@ -1430,7 +1414,6 @@ func Test_verbose_option()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_verbose')
 endfunc
 
 func Test_setcmdpos()
@@ -1533,7 +1516,7 @@ func Test_cmdlineclear_tabenter()
     call setline(1, range(30))
   [SCRIPT]
 
-  call writefile(lines, 'XtestCmdlineClearTabenter')
+  call writefile(lines, 'XtestCmdlineClearTabenter', 'D')
   let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10})
   call TermWait(buf, 25)
   " in one tab make the command line higher with CTRL-W -
@@ -1541,7 +1524,6 @@ func Test_cmdlineclear_tabenter()
   call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {})
 
   call StopVimInTerminal(buf)
-  call delete('XtestCmdlineClearTabenter')
 endfunc
 
 " Test for expanding special keywords in cmdline
@@ -1552,14 +1534,12 @@ func Test_cmdline_expand_special()
   call assert_fails('e <abuf>', 'E496:')
   call assert_fails('e <amatch>', 'E497:')
 
-  call writefile([], 'Xfile.cpp')
-  call writefile([], 'Xfile.java')
+  call writefile([], 'Xfile.cpp', 'D')
+  call writefile([], 'Xfile.java', 'D')
   new Xfile.cpp
   call feedkeys(":e %:r\<C-A>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"e Xfile.cpp Xfile.java', @:)
   close
-  call delete('Xfile.cpp')
-  call delete('Xfile.java')
 endfunc
 
 " Test for backtick expression in the command line
@@ -1593,11 +1573,10 @@ func Test_cmd_bang()
     call delete('Xfile.out')
     qall!
   [SCRIPT]
-  call writefile(lines, 'Xscript')
+  call writefile(lines, 'Xscript', 'D')
   if RunVim([], [], '--clean -S Xscript')
     call assert_equal([], readfile('Xresult'))
   endif
-  call delete('Xscript')
   call delete('Xresult')
 endfunc
 
@@ -1619,7 +1598,7 @@ endfunc
 
 " Test for using ~ for home directory in cmdline completion matches
 func Test_cmdline_expand_home()
-  call mkdir('Xexpdir')
+  call mkdir('Xexpdir', 'R')
   call writefile([], 'Xexpdir/Xfile1')
   call writefile([], 'Xexpdir/Xfile2')
   cd Xexpdir
@@ -1629,7 +1608,6 @@ func Test_cmdline_expand_home()
   call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
   let $HOME = save_HOME
   cd ..
-  call delete('Xexpdir', 'rf')
 endfunc
 
 " Test for using CTRL-\ CTRL-G in the command line to go back to normal mode
@@ -1714,8 +1692,8 @@ func Wildmode_tests()
   " Test for longest file name completion with 'fileignorecase'
   " On MS-Windows, file names are case insensitive.
   if has('unix')
-    call writefile([], 'XTESTfoo')
-    call writefile([], 'Xtestbar')
+    call writefile([], 'XTESTfoo', 'D')
+    call writefile([], 'Xtestbar', 'D')
     set nofileignorecase
     call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt')
     call assert_equal('"e XTESTfoo', @:)
@@ -1727,8 +1705,6 @@ func Wildmode_tests()
     call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt')
     call assert_equal('"e Xtest', @:)
     set fileignorecase&
-    call delete('XTESTfoo')
-    call delete('Xtestbar')
   endif
 
   %argdelete
@@ -1750,7 +1726,7 @@ func Test_wildmode()
 endfunc
 
 func Test_custom_complete_autoload()
-  call mkdir('Xcustdir/autoload', 'p')
+  call mkdir('Xcustdir/autoload', 'pR')
   let save_rtp = &rtp
   exe 'set rtp=' .. getcwd() .. '/Xcustdir'
   let lines =<< trim END
@@ -1769,7 +1745,6 @@ func Test_custom_complete_autoload()
   let &rtp = save_rtp
   set wildmode& wildmenu&
   delcommand MyCmd
-  call delete('Xcustdir', 'rf')
 endfunc
 
 " Test for interrupting the command-line completion
@@ -1946,7 +1921,7 @@ endfunc
 func Test_wildmenu_dirstack()
   CheckUnix
   %bw!
-  call mkdir('Xwildmenu/dir2/dir3/dir4', 'p')
+  call mkdir('Xwildmenu/dir2/dir3/dir4', 'pR')
   call writefile([], 'Xwildmenu/file1_1.txt')
   call writefile([], 'Xwildmenu/file1_2.txt')
   call writefile([], 'Xwildmenu/dir2/file2_1.txt')
@@ -1974,7 +1949,6 @@ func Test_wildmenu_dirstack()
   call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:)
 
-  call delete('Xwildmenu', 'rf')
   set wildmenu&
 endfunc
 
@@ -2054,9 +2028,9 @@ endfunc
 
 " Test for the 'suffixes' option
 func Test_suffixes_opt()
-  call writefile([], 'Xsuffile')
-  call writefile([], 'Xsuffile.c')
-  call writefile([], 'Xsuffile.o')
+  call writefile([], 'Xsuffile', 'D')
+  call writefile([], 'Xsuffile.c', 'D')
+  call writefile([], 'Xsuffile.o', 'D')
   set suffixes=
   call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"e Xsuffile Xsuffile.c Xsuffile.o', @:)
@@ -2076,9 +2050,6 @@ func Test_suffixes_opt()
   " Test for getcompletion() with different patterns
   call assert_equal(['Xsuffile', 'Xsuffile.c', 'Xsuffile.o'], getcompletion('Xsuffile', 'file'))
   call assert_equal(['Xsuffile'], getcompletion('Xsuffile$', 'file'))
-  call delete('Xsuffile')
-  call delete('Xsuffile.c')
-  call delete('Xsuffile.o')
 endfunc
 
 " Test for using a popup menu for the command line completion matches
@@ -2120,7 +2091,7 @@ func Test_wildmenu_pum()
       call feedkeys(":edit $VIMRUNTIME/\<Tab>\<Left>\<C-U>ab\<Tab>")
     endfunc
   [CODE]
-  call writefile(commands, 'Xtest')
+  call writefile(commands, 'Xtest', 'D')
 
   let buf = RunVimInTerminal('-S Xtest', #{rows: 10})
 
@@ -2258,7 +2229,7 @@ func Test_wildmenu_pum()
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_31', {})
 
   " Tests a directory name contained full-width characters.
-  call mkdir('Xnamedir/あいう', 'p')
+  call mkdir('Xnamedir/あいう', 'pR')
   call writefile([], 'Xnamedir/あいう/abc')
   call writefile([], 'Xnamedir/あいう/xyz')
   call writefile([], 'Xnamedir/あいう/123')
@@ -2346,8 +2317,6 @@ func Test_wildmenu_pum()
 
   call term_sendkeys(buf, "\<C-U>\<CR>")
   call StopVimInTerminal(buf)
-  call delete('Xtest')
-  call delete('Xnamedir', 'rf')
 endfunc
 
 " Test for wildmenumode() with the cmdline popup menu
@@ -2378,7 +2347,7 @@ func Test_wildmenu_with_pum_foldexpr()
       set foldtext=MyFoldText() wildoptions=pum
       normal ggzfj
   END
-  call writefile(lines, 'Xpumfold')
+  call writefile(lines, 'Xpumfold', 'D')
   let buf = RunVimInTerminal('-S Xpumfold', #{rows: 10})
   call term_sendkeys(buf, ":set\<Tab>")
   call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_1', {})
@@ -2387,7 +2356,6 @@ func Test_wildmenu_with_pum_foldexpr()
   call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_2', {})
 
   call StopVimInTerminal(buf)
-  call delete('Xpumfold')
 endfunc
 
 " Test for opening the cmdline completion popup menu from the terminal window.
@@ -2402,7 +2370,7 @@ func Test_wildmenu_pum_from_terminal()
   let cmds = ['set wildmenu wildoptions=pum']
   let pcmd = python .. ' -c "import sys; sys.stdout.write(sys.stdin.read())"'
   call add(cmds, "call term_start('" .. pcmd .. "')")
-  call writefile(cmds, 'Xtest')
+  call writefile(cmds, 'Xtest', 'D')
   let buf = RunVimInTerminal('-S Xtest', #{rows: 10})
   call term_sendkeys(buf, "\r\r\r")
   call term_wait(buf)
@@ -2411,7 +2379,6 @@ func Test_wildmenu_pum_from_terminal()
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_term_01', {})
   call term_wait(buf)
   call StopVimInTerminal(buf)
-  call delete('Xtest')
 endfunc
 
 " Test for completion after a :substitute command followed by a pipe (|)
@@ -2511,7 +2478,7 @@ endfunc
 func Test_fuzzy_completion_bufname_fullpath()
   CheckUnix
   set wildoptions&
-  call mkdir('Xcmd/Xstate/Xfile.js', 'p')
+  call mkdir('Xcmd/Xstate/Xfile.js', 'pR')
   edit Xcmd/Xstate/Xfile.js
   cd Xcmd/Xstate
   enew
@@ -2521,7 +2488,6 @@ func Test_fuzzy_completion_bufname_fullp
   call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx')
   call assert_match('Xcmd/Xstate/Xfile.js$', @:)
   cd -
-  call delete('Xcmd', 'rf')
   set wildoptions&
 endfunc
 
@@ -3028,7 +2994,7 @@ func Test_cmdline_complete_breakadd()
   call assert_equal([], l)
 
   " Test for :breakadd file [lnum] <file>
-  call writefile([], 'Xscript')
+  call writefile([], 'Xscript', 'D')
   call feedkeys(":breakadd file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
   call assert_equal("\"breakadd file Xscript", @:)
   call feedkeys(":breakadd   file   Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
@@ -3047,7 +3013,6 @@ func Test_cmdline_complete_breakadd()
   call assert_equal("\"breakadd file Xscript  ", @:)
   call feedkeys(":breakadd file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
   call assert_equal("\"breakadd file X1B2C3", @:)
-  call delete('Xscript')
 
   " Test for :breakadd func [lnum] <function>
   func Xbreak_func()
@@ -3109,7 +3074,7 @@ func Test_cmdline_complete_breakdel()
   call assert_equal("\"breakdel abc", @:)
 
   " Test for :breakdel file [lnum] <file>
-  call writefile([], 'Xscript')
+  call writefile([], 'Xscript', 'D')
   call feedkeys(":breakdel file Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
   call assert_equal("\"breakdel file Xscript", @:)
   call feedkeys(":breakdel   file   Xsc\<Tab>\<C-B>\"\<CR>", 'tx')
@@ -3128,7 +3093,6 @@ func Test_cmdline_complete_breakdel()
   call assert_equal("\"breakdel file Xscript  ", @:)
   call feedkeys(":breakdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
   call assert_equal("\"breakdel file X1B2C3", @:)
-  call delete('Xscript')
 
   " Test for :breakdel func [lnum] <function>
   func Xbreak_func()
@@ -3165,7 +3129,7 @@ endfunc
 " Test for :scriptnames argument completion
 func Test_cmdline_complete_scriptnames()
   set wildmenu
-  call writefile(['let a = 1'], 'Xa1b2c3.vim')
+  call writefile(['let a = 1'], 'Xa1b2c3.vim', 'D')
   source Xa1b2c3.vim
   call feedkeys(":script \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx')
   call assert_match("\"script .*Xa1b2c3.vim$", @:)
@@ -3185,7 +3149,6 @@ func Test_cmdline_complete_scriptnames()
   call feedkeys(":script \<Tab>\<Left>\<Left>\<CR>", 'tx')
   call assert_equal('Xa1b2c3.vim', fnamemodify(@%, ':t'))
   bw!
-  call delete('Xa1b2c3.vim')
   set wildmenu&
 endfunc
 
@@ -3259,13 +3222,12 @@ func Test_cmdline_redraw_tabline()
       set showtabline=2
       autocmd CmdlineEnter * set tabline=foo
   END
-  call writefile(lines, 'Xcmdline_redraw_tabline')
+  call writefile(lines, 'Xcmdline_redraw_tabline', 'D')
   let buf = RunVimInTerminal('-S Xcmdline_redraw_tabline', #{rows: 6})
   call term_sendkeys(buf, ':')
   call WaitForAssert({-> assert_match('^foo', term_getline(buf, 1))})
 
   call StopVimInTerminal(buf)
-  call delete('Xcmdline_redraw_tabline')
 endfunc
 
 func Test_wildmenu_pum_disable_while_shown()
--- a/src/testdir/test_cmdwin.vim
+++ b/src/testdir/test_cmdwin.vim
@@ -70,7 +70,7 @@ func Test_cmdwin_restore()
     call setline(1, range(30))
     2split
   [SCRIPT]
-  call writefile(lines, 'XTest_restore')
+  call writefile(lines, 'XTest_restore', 'D')
 
   let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12})
   call TermWait(buf, 50)
@@ -90,7 +90,6 @@ func Test_cmdwin_restore()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_restore')
 endfunc
 
 func Test_cmdwin_no_terminal()
@@ -186,7 +185,7 @@ func Test_cmdwin_interrupted()
   let lines =<< trim [SCRIPT]
     au WinNew * smile
   [SCRIPT]
-  call writefile(lines, 'XTest_cmdwin')
+  call writefile(lines, 'XTest_cmdwin', 'D')
 
   let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18})
   " open cmdwin
@@ -201,7 +200,6 @@ func Test_cmdwin_interrupted()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_cmdwin')
 endfunc
 
 " Test for recursively getting multiple command line inputs
--- a/src/testdir/test_conceal.vim
+++ b/src/testdir/test_conceal.vim
@@ -25,7 +25,7 @@ func Test_conceal_two_windows()
     exe "normal /here\r"
   [CODE]
 
-  call writefile(code, 'XTest_conceal')
+  call writefile(code, 'XTest_conceal', 'D')
   " Check that cursor line is concealed
   let buf = RunVimInTerminal('-S XTest_conceal', {})
   call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {})
@@ -109,7 +109,6 @@ func Test_conceal_two_windows()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_conceal')
 endfunc
 
 func Test_conceal_with_cursorline()
@@ -126,7 +125,7 @@ func Test_conceal_with_cursorline()
     normal M
   [CODE]
 
-  call writefile(code, 'XTest_conceal_cul')
+  call writefile(code, 'XTest_conceal_cul', 'D')
   let buf = RunVimInTerminal('-S XTest_conceal_cul', {})
   call VerifyScreenDump(buf, 'Test_conceal_cul_01', {})
 
@@ -138,7 +137,6 @@ func Test_conceal_with_cursorline()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_conceal_cul')
 endfunc
 
 func Test_conceal_resize_term()
@@ -150,7 +148,7 @@ func Test_conceal_resize_term()
     syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends
     normal fb
   [CODE]
-  call writefile(code, 'XTest_conceal_resize')
+  call writefile(code, 'XTest_conceal_resize', 'D')
   let buf = RunVimInTerminal('-S XTest_conceal_resize', {'rows': 6})
   call VerifyScreenDump(buf, 'Test_conceal_resize_01', {})
 
@@ -159,7 +157,6 @@ func Test_conceal_resize_term()
 
   " clean up
   call StopVimInTerminal(buf)
-  call delete('XTest_conceal_resize')
 endfunc
 
 " Tests for correct display (cursor column position) with +conceal and
@@ -247,7 +244,7 @@ func Test_conceal_cursor_pos()
     :q!
 
   [CODE]
-  call writefile(code, 'XTest_conceal_curpos')
+  call writefile(code, 'XTest_conceal_curpos', 'D')
 
   if RunVim([], [], '-s XTest_conceal_curpos')
     call assert_equal([
@@ -258,7 +255,6 @@ func Test_conceal_cursor_pos()
   endif
 
   call delete('Xconceal_curpos.out')
-  call delete('XTest_conceal_curpos')
 endfunc
 
 func Test_conceal_eol()
--- a/src/testdir/test_cpoptions.vim
+++ b/src/testdir/test_cpoptions.vim
@@ -8,7 +8,7 @@ source view_util.vim
 " file name.
 func Test_cpo_a()
   let save_cpo = &cpo
-  call writefile(['one'], 'XfileCpoA')
+  call writefile(['one'], 'XfileCpoA', 'D')
   " Wipe out all the buffers, so that the alternate file is empty
   edit Xfoo | %bw
   set cpo-=a
@@ -20,7 +20,6 @@ func Test_cpo_a()
   read XfileCpoA
   call assert_equal('XfileCpoA', @#)
   close!
-  call delete('XfileCpoA')
   let &cpo = save_cpo
 endfunc
 
@@ -99,21 +98,20 @@ endfunc
 " Test for the 'C' flag in 'cpo' (line continuation)
 func Test_cpo_C()
   let save_cpo = &cpo
-  call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC')
+  call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC', 'D')
   set cpo-=C
   source XfileCpoC
   call assert_equal([1, 2], g:l)
   set cpo+=C
   call assert_fails('source XfileCpoC', ['E697:', 'E10:'])
-  call delete('XfileCpoC')
   let &cpo = save_cpo
 endfunc
 
 " Test for the 'd' flag in 'cpo' (tags relative to the current file)
 func Test_cpo_d()
   let save_cpo = &cpo
-  call mkdir('XdirCpoD')
-  call writefile(["one\tXfile1\t/^one$/"], 'tags')
+  call mkdir('XdirCpoD', 'R')
+  call writefile(["one\tXfile1\t/^one$/"], 'tags', 'D')
   call writefile(["two\tXfile2\t/^two$/"], 'XdirCpoD/tags')
   set tags=./tags
   set cpo-=d
@@ -121,9 +119,8 @@ func Test_cpo_d()
   call assert_equal('two', taglist('.*')[0].name)
   set cpo+=d
   call assert_equal('one', taglist('.*')[0].name)
+
   %bw!
-  call delete('tags')
-  call delete('XdirCpoD', 'rf')
   set tags&
   let &cpo = save_cpo
 endfunc
@@ -415,14 +412,13 @@ func Test_cpo_O()
   let save_cpo = &cpo
   new XfileCpoO
   call setline(1, 'one')
-  call writefile(['two'], 'XfileCpoO')
+  call writefile(['two'], 'XfileCpoO', 'D')
   set cpo-=O
   call assert_fails('write', 'E13:')
   set cpo+=O
   write
   call assert_equal(['one'], readfile('XfileCpoO'))
   close!
-  call delete('XfileCpoO')
   let &cpo = save_cpo
 endfunc
 
@@ -432,7 +428,7 @@ endfunc
 " name)
 func Test_cpo_P()
   let save_cpo = &cpo
-  call writefile([], 'XfileCpoP')
+  call writefile([], 'XfileCpoP', 'D')
   new
   call setline(1, 'one')
   set cpo+=F
@@ -443,7 +439,6 @@ func Test_cpo_P()
   write >> XfileCpoP
   call assert_equal('XfileCpoP', @%)
   close!
-  call delete('XfileCpoP')
   let &cpo = save_cpo
 endfunc
 
@@ -635,7 +630,7 @@ endfunc
 " Test for the 'Z' flag in 'cpo' (write! resets 'readonly')
 func Test_cpo_Z()
   let save_cpo = &cpo
-  call writefile([], 'XfileCpoZ')
+  call writefile([], 'XfileCpoZ', 'D')
   new XfileCpoZ
   setlocal readonly
   set cpo-=Z
@@ -646,7 +641,6 @@ func Test_cpo_Z()
   write!
   call assert_equal(1, &readonly)
   close!
-  call delete('XfileCpoZ')
   let &cpo = save_cpo
 endfunc
 
@@ -723,7 +717,7 @@ endfunc
 " flag)
 func Test_cpo_plus()
   let save_cpo = &cpo
-  call writefile([], 'XfileCpoPlus')
+  call writefile([], 'XfileCpoPlus', 'D')
   new XfileCpoPlus
   call setline(1, 'foo')
   write X1
@@ -732,7 +726,6 @@ func Test_cpo_plus()
   write X2
   call assert_equal(0, &modified)
   close!
-  call delete('XfileCpoPlus')
   call delete('X1')
   call delete('X2')
   let &cpo = save_cpo
@@ -835,7 +828,7 @@ endfunc
 " Test for the '&' flag in 'cpo'. The swap file is kept when a buffer is still
 " loaded and ':preserve' is used.
 func Test_cpo_ampersand()
-  call writefile(['one'], 'XfileCpoAmp')
+  call writefile(['one'], 'XfileCpoAmp', 'D')
   let after =<< trim [CODE]
     set cpo+=&
     preserve
@@ -845,7 +838,6 @@ func Test_cpo_ampersand()
     call assert_equal(1, filereadable('.XfileCpoAmp.swp'))
     call delete('.XfileCpoAmp.swp')
   endif
-  call delete('XfileCpoAmp')
 endfunc
 
 " Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern)
--- a/src/testdir/test_cscope.vim
+++ b/src/testdir/test_cscope.vim
@@ -300,7 +300,7 @@ endfunc
 
 " Test ":cs add {dir}"  (add the {dir}/cscope.out database)
 func Test_cscope_add_dir()
-  call mkdir('Xcscopedir', 'p')
+  call mkdir('Xcscopedir', 'pD')
 
   " Cscope doesn't handle symlinks, so this needs to be resolved in case a
   " shadow directory is being used.
@@ -318,8 +318,6 @@ func Test_cscope_add_dir()
   cs kill -1
   call delete('Xcscopedir/cscope.out')
   call assert_fails('cs add Xcscopedir', 'E563:')
-
-  call delete('Xcscopedir', 'd')
 endfunc
 
 func Test_cscopequickfix()
--- a/src/testdir/test_cursorline.vim
+++ b/src/testdir/test_cursorline.vim
@@ -133,7 +133,7 @@ func Test_cursorline_screenline()
   call extend(lines, lines1)
   call extend(lines,  ["call append(0, ".. string(file_content).. ')'])
   call extend(lines, lines2)
-  call writefile(lines, filename)
+  call writefile(lines, filename, 'D')
   " basic test
   let buf = RunVimInTerminal('-S '. filename, #{rows: 20})
   call VerifyScreenDump(buf, 'Test_'. filename. '_1', {})
@@ -196,7 +196,6 @@ func Test_cursorline_screenline()
   call term_sendkeys(buf, ":set list& cursorlineopt& listchars&\<cr>")
 
   call StopVimInTerminal(buf)
-  call delete(filename)
 endfunc
 
 func Test_cursorline_redraw()
@@ -227,13 +226,13 @@ set all" or ":verbose set" without an ar
 When the option was set by hand there is no "Last set" message.
 When the option was set while executing a function, user command or
 END
-  call writefile(textlines, 'Xtextfile')
+  call writefile(textlines, 'Xtextfile', 'D')
 
   let script =<< trim END
       set cursorline scrolloff=2
       normal 12G
   END
-  call writefile(script, 'Xscript')
+  call writefile(script, 'Xscript', 'D')
 
   let buf = RunVimInTerminal('-S Xscript Xtextfile', #{rows: 20, cols: 40})
   call VerifyScreenDump(buf, 'Test_cursorline_redraw_1', {})
@@ -243,8 +242,6 @@ END
   call VerifyScreenDump(buf, 'Test_cursorline_redraw_2', {})
 
   call StopVimInTerminal(buf)
-  call delete('Xscript')
-  call delete('Xtextfile')
 endfunc
 
 func Test_cursorline_callback()
@@ -262,14 +259,13 @@ func Test_cursorline_callback()
 
       call timer_start(300, 'Func')
   END
-  call writefile(lines, 'Xcul_timer')
+  call writefile(lines, 'Xcul_timer', 'D')
 
   let buf = RunVimInTerminal('-S Xcul_timer', #{rows: 8})
   call TermWait(buf, 310)
   call VerifyScreenDump(buf, 'Test_cursorline_callback_1', {})
 
   call StopVimInTerminal(buf)
-  call delete('Xcul_timer')
 endfunc
 
 func Test_cursorline_screenline_update()
@@ -280,7 +276,7 @@ func Test_cursorline_screenline_update()
       set cursorline cursorlineopt=screenline
       inoremap <F2> <Cmd>call cursor(1, 1)<CR>
   END
-  call writefile(lines, 'Xcul_screenline')
+  call writefile(lines, 'Xcul_screenline', 'D')
 
   let buf = RunVimInTerminal('-S Xcul_screenline', #{rows: 8})
   call term_sendkeys(buf, "A")
@@ -290,7 +286,6 @@ func Test_cursorline_screenline_update()
   call term_sendkeys(buf, "\<Esc>")
 
   call StopVimInTerminal(buf)
-  call delete('Xcul_screenline')
 endfunc
 
 func Test_cursorline_cursorbind_horizontal_scroll()
@@ -307,7 +302,7 @@ func Test_cursorline_cursorbind_horizont
       20vsp
       windo :set cursorbind
   END
-  call writefile(lines, 'Xhor_scroll')
+  call writefile(lines, 'Xhor_scroll', 'D')
 
   let buf = RunVimInTerminal('-S Xhor_scroll', #{rows: 8})
   call term_sendkeys(buf, "20l")
@@ -326,7 +321,6 @@ func Test_cursorline_cursorbind_horizont
   call VerifyScreenDump(buf, 'Test_hor_scroll_5', {})
 
   call StopVimInTerminal(buf)
-  call delete('Xhor_scroll')
 endfunc
 
 
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    418,
+/**/
     417,
 /**/
     416,