diff src/testdir/test_terminal.vim @ 19954:c087099e9163 v8.2.0533

patch 8.2.0533: tests using term_wait() can still be flaky Commit: https://github.com/vim/vim/commit/6a2c5a7dd5c9215cc030d5ea6e4616d782c091dd Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 8 21:50:25 2020 +0200 patch 8.2.0533: tests using term_wait() can still be flaky Problem: Tests using term_wait() can still be flaky. Solution: Increase the wait time when rerunning a test. (James McCoy, closes #5899) Halve the initial times to make tests run faster when there is no rerun.
author Bram Moolenaar <Bram@vim.org>
date Wed, 08 Apr 2020 22:00:05 +0200
parents 648752e0d579
children b07672d13ff9
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -44,7 +44,7 @@ func Test_terminal_basic()
   call assert_notmatch('%[^\n]*running]', execute('ls ?'))
 
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   call assert_equal('n', mode())
   call assert_match('%aF[^\n]*finished]', execute('ls'))
   call assert_match('%aF[^\n]*finished]', execute('ls F'))
@@ -79,7 +79,7 @@ endfunc
 func Test_terminal_make_change()
   let buf = Run_shell_in_terminal({})
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
 
   setlocal modifiable
   exe "normal Axxx\<Esc>"
@@ -117,10 +117,10 @@ endfunc
 
 func Test_terminal_split_quit()
   let buf = Run_shell_in_terminal({})
-  call term_wait(buf)
+  call TermWait(buf)
   split
   quit!
-  call term_wait(buf)
+  call TermWait(buf)
   sleep 50m
   call assert_equal('run', job_status(g:job))
 
@@ -225,7 +225,7 @@ func Test_terminal_scrape_123()
   " Nothing happens with invalid buffer number
   call term_wait(1234)
 
-  call term_wait(buf)
+  call TermWait(buf)
   " On MS-Windows we first get a startup message of two lines, wait for the
   " "cls" to happen, after that we have one line with three characters.
   call WaitForAssert({-> assert_equal(3, len(term_scrape(buf, 1)))})
@@ -234,7 +234,7 @@ func Test_terminal_scrape_123()
   " Must still work after the job ended.
   let job = term_getjob(buf)
   call WaitForAssert({-> assert_equal("dead", job_status(job))})
-  call term_wait(buf)
+  call TermWait(buf)
   call Check_123(buf)
 
   exe buf . 'bwipe'
@@ -270,7 +270,7 @@ func Test_terminal_scrape_multibyte()
 
   let job = term_getjob(buf)
   call WaitForAssert({-> assert_equal("dead", job_status(job))})
-  call term_wait(buf)
+  call TermWait(buf)
 
   exe buf . 'bwipe'
   call delete('Xtext')
@@ -287,7 +287,7 @@ func Test_terminal_scroll()
 
   let job = term_getjob(buf)
   call WaitForAssert({-> assert_equal("dead", job_status(job))})
-  call term_wait(buf)
+  call TermWait(buf)
 
   " wait until the scrolling stops
   while 1
@@ -325,7 +325,7 @@ func Test_terminal_scrollback()
   call assert_inrange(91, 100, lines)
 
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
   set termwinscroll&
   call delete('Xtext')
@@ -359,10 +359,10 @@ func Test_terminal_postponed_scrollback(
 
   " stop "tail -f"
   call term_sendkeys(buf, "\<C-C>")
-  call term_wait(buf, 50)
+  call TermWait(buf, 25)
   " stop shell
   call term_sendkeys(buf, "exit\<CR>")
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   " close terminal window
   let tsk_ret = term_sendkeys(buf, ":q\<CR>")
 
@@ -622,7 +622,7 @@ func s:test_environment(name, value)
   else
     call term_sendkeys(buf, "echo $" . a:name . "\r")
   endif
-  call term_wait(buf)
+  call TermWait(buf)
   call StopShellInTerminal(buf)
   call WaitForAssert({-> assert_equal(a:value, getline(2))})
 
@@ -639,7 +639,7 @@ func Test_terminal_env()
   else
     call term_sendkeys(buf, "echo $TESTENV\r")
   endif
-  eval buf->term_wait()
+  eval buf->TermWait()
   call StopShellInTerminal(buf)
   call WaitForAssert({-> assert_equal('correct', getline(2))})
 
@@ -688,7 +688,7 @@ func Test_terminal_noblock()
 
   let g:job = term_getjob(buf)
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   unlet g:job
   bwipe
 endfunc
@@ -813,7 +813,7 @@ endfunc
 func Test_terminal_redir_file()
   let cmd = Get_cat_123_cmd()
   let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
-  call term_wait(buf)
+  call TermWait(buf)
   " ConPTY may precede escape sequence. There are things that are not so.
   if !has('conpty')
     call WaitForAssert({-> assert_notequal(0, len(readfile("Xfile")))})
@@ -827,7 +827,7 @@ func Test_terminal_redir_file()
   if has('unix')
     call writefile(['one line'], 'Xfile')
     let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
-    call term_wait(buf)
+    call TermWait(buf)
     call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))})
     let g:job = term_getjob(buf)
     call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
@@ -860,7 +860,7 @@ func TerminalTmap(remap)
 
   call term_sendkeys(buf, "\r")
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
 
   tunmap 123
   tunmap 456
@@ -878,7 +878,7 @@ func Test_terminal_wall()
   let buf = Run_shell_in_terminal({})
   wall
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
   unlet g:job
 endfunc
@@ -887,7 +887,7 @@ func Test_terminal_wqall()
   let buf = Run_shell_in_terminal({})
   call assert_fails('wqall', 'E948')
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
   unlet g:job
 endfunc
@@ -908,7 +908,7 @@ func Test_terminal_composing_unicode()
   enew
   let buf = term_start(cmd, {'curwin': bufnr('')})
   let g:job = term_getjob(buf)
-  call term_wait(buf, 50)
+  call TermWait(buf, 25)
 
   if has('win32')
     call assert_equal('cmd', job_info(g:job).cmd[0])
@@ -919,7 +919,7 @@ func Test_terminal_composing_unicode()
   " ascii + composing
   let txt = "a\u0308bc"
   call term_sendkeys(buf, "echo " . txt . "\r")
-  call term_wait(buf, 50)
+  call TermWait(buf, 25)
   call assert_match("echo " . txt, term_getline(buf, lnum[0]))
   call assert_equal(txt, term_getline(buf, lnum[0] + 1))
   let l = term_scrape(buf, lnum[0] + 1)
@@ -930,7 +930,7 @@ func Test_terminal_composing_unicode()
   " multibyte + composing
   let txt = "\u304b\u3099\u304e\u304f\u3099\u3052\u3053\u3099"
   call term_sendkeys(buf, "echo " . txt . "\r")
-  call term_wait(buf, 50)
+  call TermWait(buf, 25)
   call assert_match("echo " . txt, term_getline(buf, lnum[1]))
   call assert_equal(txt, term_getline(buf, lnum[1] + 1))
   let l = term_scrape(buf, lnum[1] + 1)
@@ -943,7 +943,7 @@ func Test_terminal_composing_unicode()
   " \u00a0 + composing
   let txt = "abc\u00a0\u0308"
   call term_sendkeys(buf, "echo " . txt . "\r")
-  call term_wait(buf, 50)
+  call TermWait(buf, 25)
   call assert_match("echo " . txt, term_getline(buf, lnum[2]))
   call assert_equal(txt, term_getline(buf, lnum[2] + 1))
   let l = term_scrape(buf, lnum[2] + 1)
@@ -1587,7 +1587,7 @@ func Test_terminal_ansicolors_default()
   let buf = Run_shell_in_terminal({})
   call assert_equal(colors, term_getansicolors(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
 
   exe buf . 'bwipe'
 endfunc
@@ -1612,7 +1612,7 @@ func Test_terminal_ansicolors_global()
   let buf = Run_shell_in_terminal({})
   call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
 
   exe buf . 'bwipe'
   unlet g:terminal_ansi_colors
@@ -1646,7 +1646,7 @@ func Test_terminal_ansicolors_func()
   call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
 
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 endfunc
 
@@ -1742,7 +1742,7 @@ func Test_terminal_termwinsize_option_ze
   let win = bufwinid(buf)
   call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 
   set termwinsize=7x0
@@ -1750,7 +1750,7 @@ func Test_terminal_termwinsize_option_ze
   let win = bufwinid(buf)
   call assert_equal([7, winwidth(win)], term_getsize(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 
   set termwinsize=0x33
@@ -1758,7 +1758,7 @@ func Test_terminal_termwinsize_option_ze
   let win = bufwinid(buf)
   call assert_equal([winheight(win), 33], term_getsize(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 
   set termwinsize=
@@ -1788,7 +1788,7 @@ func Test_terminal_termwinsize_minimum()
   call assert_equal(30, winwidth(win))
 
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 
   set termwinsize=0*0
@@ -1796,7 +1796,7 @@ func Test_terminal_termwinsize_minimum()
   let win = bufwinid(buf)
   call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 
   set termwinsize=
@@ -1938,7 +1938,7 @@ func Test_zz1_terminal_in_gui()
   call assert_equal(1, winnr('$'))
   let buf = Run_shell_in_terminal({'term_finish': 'close'})
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
 
   " closing window wipes out the terminal buffer a with finished job
   call WaitForAssert({-> assert_equal(1, winnr('$'))})
@@ -2025,7 +2025,7 @@ func Test_terminal_normal_mode()
   END
   call writefile(lines, 'XtermNormal')
   let buf = RunVimInTerminal('-S XtermNormal', {'rows': 8})
-  call term_wait(buf)
+  call TermWait(buf)
 
   call term_sendkeys(buf, "\<C-W>N")
   call term_sendkeys(buf, ":set number cursorline culopt=both\r")
@@ -2215,7 +2215,7 @@ func Test_term_gettty()
   call assert_equal('', term_gettty(buf + 1))
 
   call StopShellInTerminal(buf)
-  call term_wait(buf)
+  call TermWait(buf)
   exe buf . 'bwipe'
 endfunc
 
@@ -2255,7 +2255,7 @@ func Test_terminal_getwinpos()
 	\ 'echo getwinpos()',
 	\ ], 'XTest_getwinpos')
   let buf = RunVimInTerminal('-S XTest_getwinpos', {'cols': 60})
-  call term_wait(buf)
+  call TermWait(buf)
 
   " Find the output of getwinpos() in the bottom line.
   let rows = term_getsize(buf)[0]
@@ -2278,7 +2278,7 @@ func Test_terminal_getwinpos()
   call assert_inrange(xroot + 2, xroot + xoff, xpos)
   call assert_inrange(yroot + 2, yroot + yoff, ypos)
 
-  call term_wait(buf)
+  call TermWait(buf)
   call term_sendkeys(buf, ":q\<CR>")
   call StopVimInTerminal(buf)
   call delete('XTest_getwinpos')
@@ -2434,11 +2434,11 @@ func Test_terminal_in_popup()
 	\ ]
   call writefile(lines, 'XtermPopup')
   let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
-  call term_wait(buf, 200)
+  call TermWait(buf, 100)
   call term_sendkeys(buf, ":call OpenTerm(0)\<CR>")
-  call term_wait(buf, 200)
+  call TermWait(buf, 100)
   call term_sendkeys(buf, ":\<CR>")
-  call term_wait(buf, 200)
+  call TermWait(buf, 100)
   call term_sendkeys(buf, "\<C-W>:echo getwinvar(g:winid, \"&buftype\") win_gettype(g:winid)\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_1', {})
 
@@ -2446,7 +2446,7 @@ func Test_terminal_in_popup()
   call VerifyScreenDump(buf, 'Test_terminal_popup_2', {})
  
   call term_sendkeys(buf, ":call OpenTerm(1)\<CR>")
-  call term_wait(buf, 300)
+  call TermWait(buf, 150)
   call term_sendkeys(buf, ":set hlsearch\<CR>")
   call term_sendkeys(buf, "/edit\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_3', {})
@@ -2454,7 +2454,7 @@ func Test_terminal_in_popup()
   call term_sendkeys(buf, "\<C-W>:call HidePopup()\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_4', {})
   call term_sendkeys(buf, "\<CR>")
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
 
   call term_sendkeys(buf, "\<C-W>:call ClosePopup()\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_5', {})
@@ -2470,9 +2470,9 @@ func Test_terminal_in_popup()
   call term_sendkeys(buf, "A")
   call VerifyScreenDump(buf, 'Test_terminal_popup_8', {})
 
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   call term_sendkeys(buf, ":q\<CR>")
-  call term_wait(buf, 200)  " wait for terminal to vanish
+  call TermWait(buf, 100)  " wait for terminal to vanish
 
   call StopVimInTerminal(buf)
   call delete('Xtext')
@@ -2499,16 +2499,16 @@ func Test_terminal_in_popup_min_size()
 	\ ]
   call writefile(lines, 'XtermPopup')
   let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
-  call term_wait(buf, 200)
+  call TermWait(buf, 100)
   call term_sendkeys(buf, ":set noruler\<CR>")
   call term_sendkeys(buf, ":call OpenTerm()\<CR>")
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   call term_sendkeys(buf, ":\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_m1', {})
 
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   call term_sendkeys(buf, ":q\<CR>")
-  call term_wait(buf, 100)  " wait for terminal to vanish
+  call TermWait(buf, 50)  " wait for terminal to vanish
   call StopVimInTerminal(buf)
   call delete('Xtext')
   call delete('XtermPopup')
@@ -2531,17 +2531,17 @@ func Terminal_in_popup_colored(group_nam
 	\ ]
   call writefile(lines, 'XtermPopup')
   let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
-  call term_wait(buf, 200)
+  call TermWait(buf, 100)
   call term_sendkeys(buf, ":set noruler\<CR>")
   call term_sendkeys(buf, ":call OpenTerm()\<CR>")
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   call term_sendkeys(buf, "hello\<CR>")
   call VerifyScreenDump(buf, 'Test_terminal_popup_' .. a:group_name, {})
 
   call term_sendkeys(buf, "\<C-D>")
-  call term_wait(buf, 100)
+  call TermWait(buf, 50)
   call term_sendkeys(buf, ":q\<CR>")
-  call term_wait(buf, 100)  " wait for terminal to vanish
+  call TermWait(buf, 50)  " wait for terminal to vanish
   call StopVimInTerminal(buf)
   call delete('XtermPopup')
 endfunc
@@ -2594,19 +2594,19 @@ func Test_term_nasty_callback()
     let g:buf1 = term_start('sh', #{hidden: 1, term_finish: 'close'})
     call popup_create(g:buf1, {})
     let g:buf2 = term_start(['sh', '-c'], #{curwin: 1, exit_cb: function('TermExit')})
-    call term_wait(g:buf2, 100)
+    call TermWait(g:buf2, 50)
     call popup_close(win_getid())
   endfunc
   func TermExit(...)
     let altbuf = bufnr('#')
     call term_sendkeys(altbuf, "exit\<CR>")
-    call term_wait(altbuf)
+    call TermWait(altbuf)
     call popup_close(win_getid())
   endfunc
   call OpenTerms()
 
   call term_sendkeys(g:buf0, "exit\<CR>")
-  call term_wait(g:buf0, 100)
+  call TermWait(g:buf0, 50)
   exe g:buf0 .. 'bwipe!'
   set hidden&
 endfunc