patch 9.0.0418: manually deleting temp test files

Problem:    Manually deleting temp test files.
Solution:   Use the 'D' flag of writefile() and mkdir().
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim
index c82cefc..9fb5958 100644
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -58,18 +58,17 @@
     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 @@
 
   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 @@
 
   only | tabonly
   call chdir(topdir)
-  call delete('Xprevdir', 'rf')
 endfunc
 
 func Test_lcd_split()
@@ -201,22 +198,18 @@
 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 @@
 
   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 @@
   set noautochdir
   bwipe!
   call chdir(startdir)
-  call delete('Xactual', 'rf')
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab