To: vim_dev@googlegroups.com Subject: Patch 8.2.1498 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1498 Problem: On slow systems tests can be flaky. Solution: Use TermWait() instead of term-wait(). (Yegappan Lakshmanan, closes #6756) Files: src/testdir/test_digraph.vim, src/testdir/test_display.vim, src/testdir/test_popupwin.vim, src/testdir/test_termcodes.vim, src/testdir/test_terminal.vim, src/testdir/test_terminal3.vim, src/testdir/test_writefile.vim *** ../vim-8.2.1497/src/testdir/test_digraph.vim 2020-08-12 18:50:31.875655822 +0200 --- src/testdir/test_digraph.vim 2020-08-20 18:50:52.608921756 +0200 *************** *** 504,516 **** CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) call term_sendkeys(buf, "i\") ! call term_wait(buf) call assert_equal('?', term_getline(buf, 1)) call term_sendkeys(buf, "1") ! call term_wait(buf) call assert_equal('1', term_getline(buf, 1)) call term_sendkeys(buf, "2") ! call term_wait(buf) call assert_equal('½', term_getline(buf, 1)) call StopVimInTerminal(buf) endfunc --- 504,516 ---- CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) call term_sendkeys(buf, "i\") ! call TermWait(buf) call assert_equal('?', term_getline(buf, 1)) call term_sendkeys(buf, "1") ! call TermWait(buf) call assert_equal('1', term_getline(buf, 1)) call term_sendkeys(buf, "2") ! call TermWait(buf) call assert_equal('½', term_getline(buf, 1)) call StopVimInTerminal(buf) endfunc *** ../vim-8.2.1497/src/testdir/test_display.vim 2020-08-19 20:19:27.133486043 +0200 --- src/testdir/test_display.vim 2020-08-20 18:50:52.608921756 +0200 *************** *** 250,256 **** let buf = RunVimInTerminal('', #{cols: 20}) call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\") ! call term_wait(buf) call term_sendkeys(buf, "O\") call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4}) --- 250,256 ---- let buf = RunVimInTerminal('', #{cols: 20}) call term_sendkeys(buf, ":call setline(1, repeat('a', 21))\") ! call TermWait(buf) call term_sendkeys(buf, "O\") call VerifyScreenDump(buf, 'Test_display_scroll_at_topline', #{rows: 4}) *** ../vim-8.2.1497/src/testdir/test_popupwin.vim 2020-08-10 21:19:04.283641797 +0200 --- src/testdir/test_popupwin.vim 2020-08-20 18:50:52.612921736 +0200 *************** *** 2566,2572 **** call assert_equal(2, winnr()) let buf = term_start(&shell, #{hidden: 1}) call popup_create(buf, {}) ! call term_wait(buf, 100) call popup_clear(1) call assert_equal(2, winnr()) --- 2566,2572 ---- call assert_equal(2, winnr()) let buf = term_start(&shell, #{hidden: 1}) call popup_create(buf, {}) ! call TermWait(buf, 100) call popup_clear(1) call assert_equal(2, winnr()) *** ../vim-8.2.1497/src/testdir/test_termcodes.vim 2020-08-12 18:50:31.887655765 +0200 --- src/testdir/test_termcodes.vim 2020-08-20 18:50:52.612921736 +0200 *************** *** 1898,1906 **** CheckRunVimInTerminal let buf = RunVimInTerminal('', #{rows: 14}) call term_sendkeys(buf, ":set cmdheight=3\") ! call term_wait(buf, 100) call term_sendkeys(buf, ":set term=xxx\") ! call term_wait(buf, 100) call assert_match('builtin_dumb', term_getline(buf, 11)) call assert_match('Not found in termcap', term_getline(buf, 12)) call StopVimInTerminal(buf) --- 1898,1906 ---- CheckRunVimInTerminal let buf = RunVimInTerminal('', #{rows: 14}) call term_sendkeys(buf, ":set cmdheight=3\") ! call TermWait(buf, 100) call term_sendkeys(buf, ":set term=xxx\") ! call TermWait(buf, 100) call assert_match('builtin_dumb', term_getline(buf, 11)) call assert_match('Not found in termcap', term_getline(buf, 12)) call StopVimInTerminal(buf) *** ../vim-8.2.1497/src/testdir/test_terminal.vim 2020-08-12 18:50:31.887655765 +0200 --- src/testdir/test_terminal.vim 2020-08-20 18:50:52.612921736 +0200 *************** *** 264,274 **** let width = &columns botright vert term let buf = bufnr('$') ! call term_wait(buf, 100) exe "set columns=" .. (width / 2) redraw call term_sendkeys(buf, "キ") ! call term_wait(buf, 10) exe "set columns=" .. width exe buf . 'bwipe!' endfunc --- 264,274 ---- let width = &columns botright vert term let buf = bufnr('$') ! call TermWait(buf, 100) exe "set columns=" .. (width / 2) redraw call term_sendkeys(buf, "キ") ! call TermWait(buf, 10) exe "set columns=" .. width exe buf . 'bwipe!' endfunc *************** *** 1221,1227 **** CheckRunVimInTerminal call assert_fails("call term_dumpwrite({}, 'Xtest.dump')", 'E728:') let buf = RunVimInTerminal('', {}) ! call term_wait(buf) call assert_fails("call term_dumpwrite(buf, 'Xtest.dump', '')", 'E715:') call assert_fails("call term_dumpwrite(buf, [])", 'E730:') call writefile([], 'Xtest.dump') --- 1221,1227 ---- CheckRunVimInTerminal call assert_fails("call term_dumpwrite({}, 'Xtest.dump')", 'E728:') let buf = RunVimInTerminal('', {}) ! call TermWait(buf) call assert_fails("call term_dumpwrite(buf, 'Xtest.dump', '')", 'E715:') call assert_fails("call term_dumpwrite(buf, [])", 'E730:') call writefile([], 'Xtest.dump') *************** *** 1231,1237 **** call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:') call test_garbagecollect_now() call StopVimInTerminal(buf) ! call term_wait(buf) call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:') call assert_fails('call term_sendkeys([], ":q\")', 'E745:') call assert_equal(0, term_sendkeys(buf, ":q\")) --- 1231,1237 ---- call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:') call test_garbagecollect_now() call StopVimInTerminal(buf) ! call TermWait(buf) call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:') call assert_fails('call term_sendkeys([], ":q\")', 'E745:') call assert_equal(0, term_sendkeys(buf, ":q\")) *** ../vim-8.2.1497/src/testdir/test_terminal3.vim 2020-08-12 18:50:31.887655765 +0200 --- src/testdir/test_terminal3.vim 2020-08-20 18:50:52.612921736 +0200 *************** *** 374,380 **** call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\") call term_sendkeys(buf, ":set clipboard=\") call term_sendkeys(buf, ":set mousemodel=extend\") ! call term_wait(buf) redraw! " Use the mouse to enter the terminal window --- 374,380 ---- call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\") call term_sendkeys(buf, ":set clipboard=\") call term_sendkeys(buf, ":set mousemodel=extend\") ! call TermWait(buf) redraw! " Use the mouse to enter the terminal window *************** *** 388,396 **** call feedkeys("\\", 'xt') call test_setmouse(3, 8) call term_sendkeys(buf, "\\") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\") ! call term_wait(buf, 50) let pos = json_decode(readfile('Xbuf')[0]) call assert_equal([3, 8], pos[1:2]) --- 388,396 ---- call feedkeys("\\", 'xt') call test_setmouse(3, 8) call term_sendkeys(buf, "\\") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\") ! call TermWait(buf, 50) let pos = json_decode(readfile('Xbuf')[0]) call assert_equal([3, 8], pos[1:2]) *************** *** 400,408 **** call term_sendkeys(buf, "\") call test_setmouse(2, 16) call term_sendkeys(buf, "\y") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal('yellow', readfile('Xbuf')[0]) " Test for selecting text using doubleclick --- 400,408 ---- call term_sendkeys(buf, "\") call test_setmouse(2, 16) call term_sendkeys(buf, "\y") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal('yellow', readfile('Xbuf')[0]) " Test for selecting text using doubleclick *************** *** 411,428 **** call term_sendkeys(buf, "\\\") call test_setmouse(1, 17) call term_sendkeys(buf, "\y") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal('three four', readfile('Xbuf')[0]) " Test for selecting a line using triple click call delete('Xbuf') call test_setmouse(3, 2) call term_sendkeys(buf, "\\\\\\y") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0]) " Test for selecting a block using qudraple click --- 411,428 ---- call term_sendkeys(buf, "\\\") call test_setmouse(1, 17) call term_sendkeys(buf, "\y") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal('three four', readfile('Xbuf')[0]) " Test for selecting a line using triple click call delete('Xbuf') call test_setmouse(3, 2) call term_sendkeys(buf, "\\\\\\y") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0]) " Test for selecting a block using qudraple click *************** *** 431,439 **** call term_sendkeys(buf, "\\\\\\\") call test_setmouse(3, 13) call term_sendkeys(buf, "\y") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0]) " Test for extending a selection using right click --- 431,439 ---- call term_sendkeys(buf, "\\\\\\\") call test_setmouse(3, 13) call term_sendkeys(buf, "\y") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0]) " Test for extending a selection using right click *************** *** 442,450 **** call term_sendkeys(buf, "\\") call test_setmouse(2, 16) call term_sendkeys(buf, "\\y") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal("n yellow", readfile('Xbuf')[0]) " Test for pasting text using middle click --- 442,450 ---- call term_sendkeys(buf, "\\") call test_setmouse(2, 16) call term_sendkeys(buf, "\\y") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([@\"], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal("n yellow", readfile('Xbuf')[0]) " Test for pasting text using middle click *************** *** 452,464 **** call term_sendkeys(buf, ":let @r='bright '\") call test_setmouse(2, 22) call term_sendkeys(buf, "\"r\\") ! call term_wait(buf, 50) call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\") ! call term_wait(buf, 50) call assert_equal("red bright blue", readfile('Xbuf')[0][-15:]) " cleanup ! call term_wait(buf) call StopVimInTerminal(buf) let &mouse = save_mouse let &term = save_term --- 452,464 ---- call term_sendkeys(buf, ":let @r='bright '\") call test_setmouse(2, 22) call term_sendkeys(buf, "\"r\\") ! call TermWait(buf, 50) call term_sendkeys(buf, ":call writefile([getline(2)], 'Xbuf')\") ! call TermWait(buf, 50) call assert_equal("red bright blue", readfile('Xbuf')[0][-15:]) " cleanup ! call TermWait(buf) call StopVimInTerminal(buf) let &mouse = save_mouse let &term = save_term *************** *** 494,507 **** let buf = RunVimInTerminal('Xtest_modeless -n', {}) call term_sendkeys(buf, ":set nocompatible\") call term_sendkeys(buf, ":set mouse=\") ! call term_wait(buf) redraw! " Use the mouse to enter the terminal window call win_gotoid(prev_win) call feedkeys(MouseLeftClickCode(1, 1), 'x') call feedkeys(MouseLeftReleaseCode(1, 1), 'x') ! call term_wait(buf) call assert_equal(1, getwininfo(win_getid())[0].terminal) " Test for copying a modeless selection to clipboard --- 494,507 ---- let buf = RunVimInTerminal('Xtest_modeless -n', {}) call term_sendkeys(buf, ":set nocompatible\") call term_sendkeys(buf, ":set mouse=\") ! call TermWait(buf) redraw! " Use the mouse to enter the terminal window call win_gotoid(prev_win) call feedkeys(MouseLeftClickCode(1, 1), 'x') call feedkeys(MouseLeftReleaseCode(1, 1), 'x') ! call TermWait(buf) call assert_equal(1, getwininfo(win_getid())[0].terminal) " Test for copying a modeless selection to clipboard *************** *** 514,520 **** call assert_equal("d green y", @*) " cleanup ! call term_wait(buf) call StopVimInTerminal(buf) let &mouse = save_mouse let &term = save_term --- 514,520 ---- call assert_equal("d green y", @*) " cleanup ! call TermWait(buf) call StopVimInTerminal(buf) let &mouse = save_mouse let &term = save_term *** ../vim-8.2.1497/src/testdir/test_writefile.vim 2020-08-12 18:50:31.891655745 +0200 --- src/testdir/test_writefile.vim 2020-08-20 18:58:15.666979281 +0200 *************** *** 268,276 **** call writefile(["Line1", "Line2"], 'Xfile') let old_ftime = getftime('Xfile') let buf = RunVimInTerminal('Xfile', #{rows : 10}) ! call term_wait(buf) call term_sendkeys(buf, ":set noswapfile\") ! call term_wait(buf) " Modify the file directly. Make sure the file modification time is " different. Note that on Linux/Unix, the file is considered modified --- 268,276 ---- call writefile(["Line1", "Line2"], 'Xfile') let old_ftime = getftime('Xfile') let buf = RunVimInTerminal('Xfile', #{rows : 10}) ! call TermWait(buf) call term_sendkeys(buf, ":set noswapfile\") ! call TermWait(buf) " Modify the file directly. Make sure the file modification time is " different. Note that on Linux/Unix, the file is considered modified *************** *** 286,302 **** " Try to overwrite the file and check for the prompt call term_sendkeys(buf, ":w\") ! call term_wait(buf) 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)?", \ term_getline(buf, 10)) call term_sendkeys(buf, "n\") ! call term_wait(buf) call assert_equal(new_ftime, getftime('Xfile')) call term_sendkeys(buf, ":w\") ! call term_wait(buf) call term_sendkeys(buf, "y\") ! call term_wait(buf) call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])}) " clean up --- 286,302 ---- " Try to overwrite the file and check for the prompt call term_sendkeys(buf, ":w\") ! call TermWait(buf) 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)?", \ term_getline(buf, 10)) call term_sendkeys(buf, "n\") ! call TermWait(buf) call assert_equal(new_ftime, getftime('Xfile')) call term_sendkeys(buf, ":w\") ! call TermWait(buf) call term_sendkeys(buf, "y\") ! call TermWait(buf) call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])}) " clean up *************** *** 671,677 **** set cpoptions-=S let &fileencoding = save_fileencoding call delete('Xtest1') ! call delete('Xtest2') call delete('Xtest3') %bw! endfunc --- 671,677 ---- set cpoptions-=S let &fileencoding = save_fileencoding call delete('Xtest1') ! call delete('Xfile2') call delete('Xtest3') %bw! endfunc *** ../vim-8.2.1497/src/version.c 2020-08-20 18:29:06.800094041 +0200 --- src/version.c 2020-08-20 18:53:09.532313323 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1498, /**/ -- Emacs is a nice OS - but it lacks a good text editor. That's why I am using Vim. --Anonymous /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///