diff src/testdir/test_terminal2.vim @ 30865:c8ebe35b2475 v9.0.0767

patch 9.0.0767: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/c4860bdd2832feb7ab054c6dc14f68abe24c2373 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 15 20:52:26 2022 +0100 patch 9.0.0767: 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 Sat, 15 Oct 2022 22:00:04 +0200
parents 13b02c1ea0f7
children 8f15c56ff2fb
line wrap: on
line diff
--- a/src/testdir/test_terminal2.vim
+++ b/src/testdir/test_terminal2.vim
@@ -19,7 +19,7 @@ func Test_terminal_termwinsize_option_fi
   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 @@ func Test_terminal_termwinsize_option_fi
   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 @@ func Test_terminal_out_err()
 	\ '#!/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 @@ func Test_terminal_out_err()
 
   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 @@ func Test_zz1_terminal_in_gui()
   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 @@ func Test_terminal_normal_mode()
     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 @@ func Test_terminal_normal_mode()
   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 @@ func Test_terminal_does_not_truncate_las
   \ ]
 
   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 @@ func Test_terminal_does_not_truncate_las
     call assert_equal(c, getline(1, line('$')))
     quit
   endfor
-
-  call delete('Xdntfile')
 endfunc
 
 func GetDummyCmd()