diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-15 20:52:26 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-15 20:52:26 +0100 |
commit | c4860bdd2832feb7ab054c6dc14f68abe24c2373 (patch) | |
tree | 24422c7d419b358aea790c09da91344190728815 /src/testdir/test_terminal2.vim | |
parent | 0e9bdad545e8e75b23c40e44cc6ec51330f5b465 (diff) | |
download | vim-git-c4860bdd2832feb7ab054c6dc14f68abe24c2373.tar.gz |
patch 9.0.0767: too many delete() calls in testsv9.0.0767
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
Diffstat (limited to 'src/testdir/test_terminal2.vim')
-rw-r--r-- | src/testdir/test_terminal2.vim | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim index 6e70ad6cc..c6acb99bc 100644 --- a/src/testdir/test_terminal2.vim +++ b/src/testdir/test_terminal2.vim @@ -19,7 +19,7 @@ func Test_terminal_termwinsize_option_fixed() 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_fixed() 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_last_newlines() \ ] 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_last_newlines() call assert_equal(c, getline(1, line('$'))) quit endfor - - call delete('Xdntfile') endfunc func GetDummyCmd() |