From 157241e8798fe1c14f3787ee341ffee2c403714a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 9 Nov 2022 23:29:14 +0000 Subject: [PATCH] patch 9.0.0849: terminal mouse test is a bit flaky Problem: Terminal mouse test is a bit flaky. Solution: Add WaitFor() calls. (James McCoy closes #11519) Tune wait times to reduce flakiness. --- src/testdir/test_terminal3.vim | 39 +++++++++++++++++++--------------- src/version.c | 2 ++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/testdir/test_terminal3.vim b/src/testdir/test_terminal3.vim index 5b143719b..59fba9679 100644 --- a/src/testdir/test_terminal3.vim +++ b/src/testdir/test_terminal3.vim @@ -267,11 +267,11 @@ func Test_terminal_in_popup() \ ] call writefile(lines, 'XtermPopup', 'D') let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) - call TermWait(buf, 100) + call TermWait(buf, 200) call term_sendkeys(buf, ":call OpenTerm(0)\") - call TermWait(buf, 500) + call TermWait(buf, 800) call term_sendkeys(buf, ":\") - call TermWait(buf, 100) + call TermWait(buf, 500) call term_sendkeys(buf, "\:echo getwinvar(g:winid, \"&buftype\") win_gettype(g:winid)\") call VerifyScreenDump(buf, 'Test_terminal_popup_1', {}) @@ -279,9 +279,9 @@ func Test_terminal_in_popup() call VerifyScreenDump(buf, 'Test_terminal_popup_2', {}) call term_sendkeys(buf, ":call OpenTerm(1)\") - call TermWait(buf, 500) + call TermWait(buf, 800) call term_sendkeys(buf, ":set hlsearch\") - call TermWait(buf, 100) + call TermWait(buf, 500) call term_sendkeys(buf, "/edit\") call VerifyScreenDump(buf, 'Test_terminal_popup_3', {}) @@ -686,6 +686,8 @@ func Test_term_mouse() call TermWait(buf) redraw! + let XbufExists = {-> filereadable('Xbuf')} + " Use the mouse to enter the terminal window call win_gotoid(prev_win) call feedkeys(MouseLeftClickCode(1, 1), 'x') @@ -698,73 +700,76 @@ func Test_term_mouse() call test_setmouse(3, 8) call term_sendkeys(buf, "\\") call TermWait(buf, 50) + call delete('Xbuf') call term_sendkeys(buf, ":call writefile([json_encode(getpos('.'))], 'Xbuf')\") call TermWait(buf, 50) + call WaitFor(XbufExists) let pos = json_decode(readfile('Xbuf')[0]) call assert_equal([3, 8], pos[1:2]) + call delete('Xbuf') " Test for selecting text using mouse - call delete('Xbuf') call test_setmouse(2, 11) 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 WaitFor(XbufExists) call assert_equal('yellow', readfile('Xbuf')[0]) + call delete('Xbuf') " Test for selecting text using double click - call delete('Xbuf') call test_setmouse(1, 11) 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 WaitFor(XbufExists) call assert_equal('three four', readfile('Xbuf')[0]) + call delete('Xbuf') " 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 WaitFor(XbufExists) call assert_equal("vim emacs sublime nano\n", readfile('Xbuf')[0]) + call delete('Xbuf') " Test for selecting a block using quadruple click - call delete('Xbuf') call test_setmouse(1, 11) 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 WaitFor(XbufExists) call assert_equal("ree\nyel\nsub", readfile('Xbuf')[0]) + call delete('Xbuf') " Test for extending a selection using right click - call delete('Xbuf') call test_setmouse(2, 9) 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 WaitFor(XbufExists) call assert_equal("n yellow", readfile('Xbuf')[0]) + call delete('Xbuf') " Test for pasting text using middle click - call delete('Xbuf') 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 WaitFor(XbufExists) call assert_equal("red bright blue", readfile('Xbuf')[0][-15:]) + call delete('Xbuf') " cleanup call TermWait(buf) diff --git a/src/version.c b/src/version.c index b1333d284..6884514cd 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 849, /**/ 848, /**/ -- 2.40.0