0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1498: on slow systems tests can be flaky

Problem:    On slow systems tests can be flaky.
Solution:   Use TermWait() instead of term-wait(). (Yegappan Lakshmanan,
            closes #6756)
This commit is contained in:
Bram Moolenaar
2020-08-20 18:59:06 +02:00
parent 17f67547f3
commit 733d259a83
8 changed files with 39 additions and 37 deletions

View File

@@ -504,13 +504,13 @@ func Test_entering_digraph()
CheckRunVimInTerminal CheckRunVimInTerminal
let buf = RunVimInTerminal('', {'rows': 6}) let buf = RunVimInTerminal('', {'rows': 6})
call term_sendkeys(buf, "i\<C-K>") call term_sendkeys(buf, "i\<C-K>")
call term_wait(buf) call TermWait(buf)
call assert_equal('?', term_getline(buf, 1)) call assert_equal('?', term_getline(buf, 1))
call term_sendkeys(buf, "1") call term_sendkeys(buf, "1")
call term_wait(buf) call TermWait(buf)
call assert_equal('1', term_getline(buf, 1)) call assert_equal('1', term_getline(buf, 1))
call term_sendkeys(buf, "2") call term_sendkeys(buf, "2")
call term_wait(buf) call TermWait(buf)
call assert_equal('½', term_getline(buf, 1)) call assert_equal('½', term_getline(buf, 1))
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc

View File

@@ -250,7 +250,7 @@ func Test_display_scroll_at_topline()
let buf = RunVimInTerminal('', #{cols: 20}) let buf = RunVimInTerminal('', #{cols: 20})
call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\<CR>") call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\<CR>")
call term_wait(buf) call TermWait(buf)
call term_sendkeys(buf, "O\<Esc>") call term_sendkeys(buf, "O\<Esc>")
call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4}) call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4})

View File

@@ -2566,7 +2566,7 @@ func Test_popupwin_close_prevwin()
call assert_equal(2, winnr()) call assert_equal(2, winnr())
let buf = term_start(&shell, #{hidden: 1}) let buf = term_start(&shell, #{hidden: 1})
call popup_create(buf, {}) call popup_create(buf, {})
call term_wait(buf, 100) call TermWait(buf, 100)
call popup_clear(1) call popup_clear(1)
call assert_equal(2, winnr()) call assert_equal(2, winnr())

View File

@@ -1898,9 +1898,9 @@ func Test_list_builtin_terminals()
CheckRunVimInTerminal CheckRunVimInTerminal
let buf = RunVimInTerminal('', #{rows: 14}) let buf = RunVimInTerminal('', #{rows: 14})
call term_sendkeys(buf, ":set cmdheight=3\<CR>") call term_sendkeys(buf, ":set cmdheight=3\<CR>")
call term_wait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":set term=xxx\<CR>") call term_sendkeys(buf, ":set term=xxx\<CR>")
call term_wait(buf, 100) call TermWait(buf, 100)
call assert_match('builtin_dumb', term_getline(buf, 11)) call assert_match('builtin_dumb', term_getline(buf, 11))
call assert_match('Not found in termcap', term_getline(buf, 12)) call assert_match('Not found in termcap', term_getline(buf, 12))
call StopVimInTerminal(buf) call StopVimInTerminal(buf)

View File

@@ -264,11 +264,11 @@ func Test_terminal_one_column()
let width = &columns let width = &columns
botright vert term botright vert term
let buf = bufnr('$') let buf = bufnr('$')
call term_wait(buf, 100) call TermWait(buf, 100)
exe "set columns=" .. (width / 2) exe "set columns=" .. (width / 2)
redraw redraw
call term_sendkeys(buf, "キ") call term_sendkeys(buf, "キ")
call term_wait(buf, 10) call TermWait(buf, 10)
exe "set columns=" .. width exe "set columns=" .. width
exe buf . 'bwipe!' exe buf . 'bwipe!'
endfunc endfunc
@@ -1221,7 +1221,7 @@ func Test_terminal_dumpwrite_errors()
CheckRunVimInTerminal CheckRunVimInTerminal
call assert_fails("call term_dumpwrite({}, 'Xtest.dump')", 'E728:') call assert_fails("call term_dumpwrite({}, 'Xtest.dump')", 'E728:')
let buf = RunVimInTerminal('', {}) let buf = RunVimInTerminal('', {})
call term_wait(buf) call TermWait(buf)
call assert_fails("call term_dumpwrite(buf, 'Xtest.dump', '')", 'E715:') call assert_fails("call term_dumpwrite(buf, 'Xtest.dump', '')", 'E715:')
call assert_fails("call term_dumpwrite(buf, [])", 'E730:') call assert_fails("call term_dumpwrite(buf, [])", 'E730:')
call writefile([], 'Xtest.dump') call writefile([], 'Xtest.dump')
@@ -1231,7 +1231,7 @@ func Test_terminal_dumpwrite_errors()
call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:') call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:')
call test_garbagecollect_now() call test_garbagecollect_now()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call term_wait(buf) call TermWait(buf)
call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:') call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:')
call assert_fails('call term_sendkeys([], ":q\<CR>")', 'E745:') call assert_fails('call term_sendkeys([], ":q\<CR>")', 'E745:')
call assert_equal(0, term_sendkeys(buf, ":q\<CR>")) call assert_equal(0, term_sendkeys(buf, ":q\<CR>"))

View File

@@ -374,7 +374,7 @@ func Test_term_mouse()
call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>") call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>")
call term_sendkeys(buf, ":set clipboard=\<CR>") call term_sendkeys(buf, ":set clipboard=\<CR>")
call term_sendkeys(buf, ":set mousemodel=extend\<CR>") call term_sendkeys(buf, ":set mousemodel=extend\<CR>")
call term_wait(buf) call TermWait(buf)
redraw! redraw!
" Use the mouse to enter the terminal window " Use the mouse to enter the terminal window
@@ -388,9 +388,9 @@ func Test_term_mouse()
call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt') call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt')
call test_setmouse(3, 8) call test_setmouse(3, 8)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
let pos = json_decode(readfile('Xbuf')[0]) let pos = json_decode(readfile('Xbuf')[0])
call assert_equal([3, 8], pos[1:2]) call assert_equal([3, 8], pos[1:2])
@@ -400,9 +400,9 @@ func Test_term_mouse()
call term_sendkeys(buf, "\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>")
call test_setmouse(2, 16) call test_setmouse(2, 16)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal('yellow', readfile('Xbuf')[0]) call assert_equal('yellow', readfile('Xbuf')[0])
" Test for selecting text using doubleclick " Test for selecting text using doubleclick
@@ -411,18 +411,18 @@ func Test_term_mouse()
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>")
call test_setmouse(1, 17) call test_setmouse(1, 17)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal('three four', readfile('Xbuf')[0]) call assert_equal('three four', readfile('Xbuf')[0])
" Test for selecting a line using triple click " Test for selecting a line using triple click
call delete('Xbuf') call delete('Xbuf')
call test_setmouse(3, 2) call test_setmouse(3, 2)
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>y") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>y")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0]) call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0])
" Test for selecting a block using qudraple click " Test for selecting a block using qudraple click
@@ -431,9 +431,9 @@ func Test_term_mouse()
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>\<LeftRelease>\<LeftMouse>")
call test_setmouse(3, 13) call test_setmouse(3, 13)
call term_sendkeys(buf, "\<LeftRelease>y") call term_sendkeys(buf, "\<LeftRelease>y")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0]) call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0])
" Test for extending a selection using right click " Test for extending a selection using right click
@@ -442,9 +442,9 @@ func Test_term_mouse()
call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>") call term_sendkeys(buf, "\<LeftMouse>\<LeftRelease>")
call test_setmouse(2, 16) call test_setmouse(2, 16)
call term_sendkeys(buf, "\<RightMouse>\<RightRelease>y") call term_sendkeys(buf, "\<RightMouse>\<RightRelease>y")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal("n yellow", readfile('Xbuf')[0]) call assert_equal("n yellow", readfile('Xbuf')[0])
" Test for pasting text using middle click " Test for pasting text using middle click
@@ -452,13 +452,13 @@ func Test_term_mouse()
call term_sendkeys(buf, ":let @r='bright '\<CR>") call term_sendkeys(buf, ":let @r='bright '\<CR>")
call test_setmouse(2, 22) call test_setmouse(2, 22)
call term_sendkeys(buf, "\"r\<MiddleMouse>\<MiddleRelease>") call term_sendkeys(buf, "\"r\<MiddleMouse>\<MiddleRelease>")
call term_wait(buf, 50) call TermWait(buf, 50)
call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\<CR>") call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\<CR>")
call term_wait(buf, 50) call TermWait(buf, 50)
call assert_equal("red bright blue", readfile('Xbuf')[0][-15:]) call assert_equal("red bright blue", readfile('Xbuf')[0][-15:])
" cleanup " cleanup
call term_wait(buf) call TermWait(buf)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
let &mouse = save_mouse let &mouse = save_mouse
let &term = save_term let &term = save_term
@@ -494,14 +494,14 @@ func Test_term_modeless_selection()
let buf = RunVimInTerminal('Xtest_modeless -n', {}) let buf = RunVimInTerminal('Xtest_modeless -n', {})
call term_sendkeys(buf, ":set nocompatible\<CR>") call term_sendkeys(buf, ":set nocompatible\<CR>")
call term_sendkeys(buf, ":set mouse=\<CR>") call term_sendkeys(buf, ":set mouse=\<CR>")
call term_wait(buf) call TermWait(buf)
redraw! redraw!
" Use the mouse to enter the terminal window " Use the mouse to enter the terminal window
call win_gotoid(prev_win) call win_gotoid(prev_win)
call feedkeys(MouseLeftClickCode(1, 1), 'x') call feedkeys(MouseLeftClickCode(1, 1), 'x')
call feedkeys(MouseLeftReleaseCode(1, 1), 'x') call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
call term_wait(buf) call TermWait(buf)
call assert_equal(1, getwininfo(win_getid())[0].terminal) call assert_equal(1, getwininfo(win_getid())[0].terminal)
" Test for copying a modeless selection to clipboard " Test for copying a modeless selection to clipboard
@@ -514,7 +514,7 @@ func Test_term_modeless_selection()
call assert_equal("d green y", @*) call assert_equal("d green y", @*)
" cleanup " cleanup
call term_wait(buf) call TermWait(buf)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
let &mouse = save_mouse let &mouse = save_mouse
let &term = save_term let &term = save_term

View File

@@ -268,9 +268,9 @@ func Test_write_file_mtime()
call writefile(["Line1", "Line2"], 'Xfile') call writefile(["Line1", "Line2"], 'Xfile')
let old_ftime = getftime('Xfile') let old_ftime = getftime('Xfile')
let buf = RunVimInTerminal('Xfile', #{rows : 10}) let buf = RunVimInTerminal('Xfile', #{rows : 10})
call term_wait(buf) call TermWait(buf)
call term_sendkeys(buf, ":set noswapfile\<CR>") call term_sendkeys(buf, ":set noswapfile\<CR>")
call term_wait(buf) call TermWait(buf)
" Modify the file directly. Make sure the file modification time is " Modify the file directly. Make sure the file modification time is
" different. Note that on Linux/Unix, the file is considered modified " different. Note that on Linux/Unix, the file is considered modified
@@ -286,17 +286,17 @@ func Test_write_file_mtime()
" Try to overwrite the file and check for the prompt " Try to overwrite the file and check for the prompt
call term_sendkeys(buf, ":w\<CR>") call term_sendkeys(buf, ":w\<CR>")
call term_wait(buf) call TermWait(buf)
call WaitForAssert({-> assert_equal("WARNING: The file has been changed since reading it!!!", term_getline(buf, 9))}) call WaitForAssert({-> assert_equal("WARNING: The file has been changed since reading it!!!", term_getline(buf, 9))})
call assert_equal("Do you really want to write to it (y/n)?", call assert_equal("Do you really want to write to it (y/n)?",
\ term_getline(buf, 10)) \ term_getline(buf, 10))
call term_sendkeys(buf, "n\<CR>") call term_sendkeys(buf, "n\<CR>")
call term_wait(buf) call TermWait(buf)
call assert_equal(new_ftime, getftime('Xfile')) call assert_equal(new_ftime, getftime('Xfile'))
call term_sendkeys(buf, ":w\<CR>") call term_sendkeys(buf, ":w\<CR>")
call term_wait(buf) call TermWait(buf)
call term_sendkeys(buf, "y\<CR>") call term_sendkeys(buf, "y\<CR>")
call term_wait(buf) call TermWait(buf)
call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])}) call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])})
" clean up " clean up
@@ -671,7 +671,7 @@ func Test_readwrite_file_with_bom()
set cpoptions-=S set cpoptions-=S
let &fileencoding = save_fileencoding let &fileencoding = save_fileencoding
call delete('Xtest1') call delete('Xtest1')
call delete('Xtest2') call delete('Xfile2')
call delete('Xtest3') call delete('Xtest3')
%bw! %bw!
endfunc endfunc

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1498,
/**/ /**/
1497, 1497,
/**/ /**/