patch 9.0.0767: too many delete() calls in tests

Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.
diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim
index 6e70ad6..c6acb99 100644
--- a/src/testdir/test_terminal2.vim
+++ b/src/testdir/test_terminal2.vim
@@ -19,7 +19,7 @@
   for n in range(10)
     call add(text, repeat(n, 50))
   endfor
-  call writefile(text, 'Xwinsize')
+  call writefile(text, 'Xwinsize', 'D')
   let buf = RunVimInTerminal('Xwinsize', {})
   let win = bufwinid(buf)
   call assert_equal([6, 40], term_getsize(buf))
@@ -34,7 +34,6 @@
   call assert_equal(60, winwidth(win))
 
   call StopVimInTerminal(buf)
-  call delete('Xwinsize')
 
   call assert_fails('set termwinsize=40', 'E474:')
   call assert_fails('set termwinsize=10+40', 'E474:')
@@ -192,7 +191,7 @@
 	\ '#!/bin/sh',
 	\ 'echo "this is standard error" >&2',
 	\ 'echo "this is standard out" >&1',
-	\ ], 'Xechoerrout.sh')
+	\ ], 'Xechoerrout.sh', 'D')
   call setfperm('Xechoerrout.sh', 'rwxrwx---')
 
   let outfile = 'Xtermstdout'
@@ -204,7 +203,6 @@
 
   call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
   exe buf . 'bwipe'
-  call delete('Xechoerrout.sh')
   call delete(outfile)
 endfunc
 
@@ -290,36 +288,34 @@
   unlet g:job
 endfunc
 
-" TODO: re-enable when this no longer hangs on Travis
-"func Test_zz2_terminal_guioptions_bang()
-"  CheckGui
-"  set guioptions+=!
-"
-"  let filename = 'Xtestscript'
-"  if has('win32')
-"    let filename .= '.bat'
-"    let prefix = ''
-"    let contents = ['@echo off', 'exit %1']
-"  else
-"    let filename .= '.sh'
-"    let prefix = './'
-"    let contents = ['#!/bin/sh', 'exit $1']
-"  endif
-"  call writefile(contents, filename)
-"  call setfperm(filename, 'rwxrwx---')
-"
-"  " Check if v:shell_error is equal to the exit status.
-"  let exitval = 0
-"  execute printf(':!%s%s %d', prefix, filename, exitval)
-"  call assert_equal(exitval, v:shell_error)
-"
-"  let exitval = 9
-"  execute printf(':!%s%s %d', prefix, filename, exitval)
-"  call assert_equal(exitval, v:shell_error)
-"
-"  set guioptions&
-"  call delete(filename)
-"endfunc
+func Test_zz2_terminal_guioptions_bang()
+  CheckGui
+  set guioptions+=!
+
+  let filename = 'Xtestscript'
+  if has('win32')
+    let filename .= '.bat'
+    let prefix = ''
+    let contents = ['@echo off', 'exit %1']
+  else
+    let filename .= '.sh'
+    let prefix = './'
+    let contents = ['#!/bin/sh', 'exit $1']
+  endif
+  call writefile(contents, filename, 'D')
+  call setfperm(filename, 'rwxrwx---')
+
+  " Check if v:shell_error is equal to the exit status.
+  let exitval = 0
+  execute printf(':!%s%s %d', prefix, filename, exitval)
+  call assert_equal(exitval, v:shell_error)
+
+  let exitval = 9
+  execute printf(':!%s%s %d', prefix, filename, exitval)
+  call assert_equal(exitval, v:shell_error)
+
+  set guioptions&
+endfunc
 
 func Test_terminal_hidden()
   CheckUnix
@@ -372,7 +368,7 @@
     call setline(1, range(11111, 11122))
     3
   END
-  call writefile(lines, 'XtermNormal')
+  call writefile(lines, 'XtermNormal', 'D')
   let buf = RunVimInTerminal('-S XtermNormal', {'rows': 8})
   call TermWait(buf)
 
@@ -389,7 +385,6 @@
   call assert_fails('call term_sendkeys(buf, [])', 'E730:')
   call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>")
   call StopVimInTerminal(buf)
-  call delete('XtermNormal')
 endfunc
 
 func Test_terminal_hidden_and_close()
@@ -415,7 +410,7 @@
   \ ]
 
   for c in contents
-    call writefile(c, 'Xdntfile')
+    call writefile(c, 'Xdntfile', 'D')
     if has('win32')
       term cmd /c type Xdntfile
     else
@@ -428,8 +423,6 @@
     call assert_equal(c, getline(1, line('$')))
     quit
   endfor
-
-  call delete('Xdntfile')
 endfunc
 
 func GetDummyCmd()