Patch 8.2.0808 Problem: Not enough testing for the terminal window. Solution: Add more tests. (Yegappan Lakshmanan, closes #6069) Fix memory leak. Files: src/testdir/test_gui.vim, src/testdir/test_terminal.vim, src/terminal.c
*** ../vim-8.2.0807/src/testdir/test_gui.vim 2020-05-15 22:46:40.759917714 +0200 --- src/testdir/test_gui.vim 2020-05-22 13:26:35.228888857 +0200 *************** *** 850,857 **** " assume all the other systems have a cat command let cmd = 'cat' endif ! let cmd = ':silent !' . cmd . " test_gui.vim\<CR>\<CR>" ! call feedkeys(cmd, 'xt') " TODO: how to check that the command ran in a separate terminal? " Maybe check for $TERM (dumb vs xterm) in the spawned shell? let &guioptions = save_guioptions --- 850,856 ---- " assume all the other systems have a cat command let cmd = 'cat' endif ! exe "silent !" . cmd . " test_gui.vim" " TODO: how to check that the command ran in a separate terminal? " Maybe check for $TERM (dumb vs xterm) in the spawned shell? let &guioptions = save_guioptions *** ../vim-8.2.0807/src/testdir/test_terminal.vim 2020-05-21 20:38:28.039879979 +0200 --- src/testdir/test_terminal.vim 2020-05-22 13:26:35.228888857 +0200 *************** *** 1220,1225 **** --- 1220,1226 ---- call delete('Xtest.dump') call assert_fails("call term_dumpwrite(buf, '')", 'E482:') 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:') *************** *** 1305,1310 **** --- 1306,1321 ---- call assert_match('three four five', getline(3)) call assert_match('Undo', getline(45)) quit + + " Diff two terminal dump files with different number of rows + " Swap the diffs + call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_winline_rnu.dump') + call assert_match('Test_popup_command_01.dump', getline(21)) + call assert_match('Test_winline_rnu.dump', getline(42)) + normal s + call assert_match('Test_winline_rnu.dump', getline(6)) + call assert_match('Test_popup_command_01.dump', getline(27)) + quit endfunc func Test_terminal_dumpdiff_options() *************** *** 1619,1624 **** --- 1630,1636 ---- call assert_equal(colors, term_getansicolors(buf)) call StopShellInTerminal(buf) call TermWait(buf) + call assert_equal([], term_getansicolors(buf)) exe buf . 'bwipe' endfunc *************** *** 1673,1681 **** --- 1685,1695 ---- let colors[4] = 'Invalid' call assert_fails('call term_setansicolors(buf, colors)', 'E474:') + call assert_fails('call term_setansicolors(buf, {})', 'E714:') call StopShellInTerminal(buf) call TermWait(buf) + call assert_equal(0, term_setansicolors(buf, [])) exe buf . 'bwipe' endfunc *************** *** 2029,2035 **** call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("A", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) ! call feedkeys("\<C-W>N", 'xt') call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("I", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) --- 2043,2049 ---- call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("A", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) ! call feedkeys("\<C-\>\<C-N>", 'xt') call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) call feedkeys("I", 'xt') call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) *************** *** 2066,2071 **** --- 2080,2086 ---- call term_sendkeys(buf, ":set culopt=line\r") call VerifyScreenDump(buf, 'Test_terminal_normal_3', {}) + 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') *************** *** 2178,2194 **** call StopShellInTerminal(buf) endfunc func Test_term_gettitle() " term_gettitle() returns an empty string for a non-terminal buffer " and for a non-existing buffer. call assert_equal('', bufnr('%')->term_gettitle()) call assert_equal('', term_gettitle(bufnr('$') + 1)) ! if !has('title') || &title == 0 || empty(&t_ts) throw "Skipped: can't get/set title" endif ! let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile']) if has('autoservername') call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) }) call term_sendkeys(term, ":e Xfoo\r") --- 2193,2210 ---- call StopShellInTerminal(buf) endfunc + " Test for term_gettitle() func Test_term_gettitle() " term_gettitle() returns an empty string for a non-terminal buffer " and for a non-existing buffer. call assert_equal('', bufnr('%')->term_gettitle()) call assert_equal('', term_gettitle(bufnr('$') + 1)) ! if !has('title') || empty(&t_ts) throw "Skipped: can't get/set title" endif ! let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title']) if has('autoservername') call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) }) call term_sendkeys(term, ":e Xfoo\r") *************** *** 2692,2706 **** call assert_equal(output[i], term_getline(buf, 1)) endfor - "call term_sendkeys(buf, "\<K0>\<K1>\<K2>\<K3>\<K4>\<K5>\<K6>\<K7>\<K8>\<K9>") - "call term_sendkeys(buf, "\<kEnter>\<kPoint>\<kPlus>") - "call term_sendkeys(buf, "\<kMinus>\<kMultiply>\<kDivide>") - "call term_sendkeys(buf, "\<Esc>") - "call term_sendkeys(buf, "\<Home>\<Ins>\<Tab>\<S-Tab>") - "call term_sendkeys(buf, "\<Esc>") - - "call term_sendkeys(buf, ":write Xkeycodes\<CR>") - let keypad_keys = ["\<k0>", "\<k1>", "\<k2>", "\<k3>", "\<k4>", "\<k5>", \ "\<k6>", "\<k7>", "\<k8>", "\<k9>", "\<kPoint>", "\<kPlus>", \ "\<kMinus>", "\<kMultiply>", "\<kDivide>"] --- 2708,2713 ---- *************** *** 2733,2739 **** let save_term = &term let save_ttymouse = &ttymouse let save_clipboard = &clipboard - call test_override('no_query_mouse', 1) set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard= let lines =<< trim END --- 2740,2745 ---- *************** *** 2743,2748 **** --- 2749,2756 ---- END call writefile(lines, 'Xtest_mouse') + " Create a terminal window running Vim for the test with mouse enabled + let prev_win = win_getid() let buf = RunVimInTerminal('Xtest_mouse -n', {}) call term_sendkeys(buf, ":set nocompatible\<CR>") call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>") *************** *** 2751,2756 **** --- 2759,2770 ---- 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 assert_equal(1, getwininfo(win_getid())[0].terminal) + " Test for <LeftMouse> click/release call test_setmouse(2, 5) call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt') *************** *** 2833,2839 **** let &ttymouse = save_ttymouse let &clipboard = save_clipboard set mousetime& - call test_override('no_query_mouse', 0) call delete('Xtest_mouse') call delete('Xbuf') endfunc --- 2847,2852 ---- *************** *** 2848,2854 **** let save_mouse = &mouse let save_term = &term let save_ttymouse = &ttymouse - call test_override('no_query_mouse', 1) set mouse=a term=xterm ttymouse=sgr mousetime=200 set clipboard=autoselectml --- 2861,2866 ---- *************** *** 2859,2870 **** --- 2871,2891 ---- END call writefile(lines, 'Xtest_modeless') + " Create a terminal window running Vim for the test with mouse disabled + let prev_win = win_getid() let buf = RunVimInTerminal('Xtest_modeless -n', {}) call term_sendkeys(buf, ":set nocompatible\<CR>") call term_sendkeys(buf, ":set mouse=\<CR>") 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 let @* = 'clean' " communicating with X server may take a little time *************** *** 2881,2888 **** let &term = save_term let &ttymouse = save_ttymouse set mousetime& clipboard& - call test_override('no_query_mouse', 0) call delete('Xtest_modeless') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 2902,2909 ---- let &term = save_term let &ttymouse = save_ttymouse set mousetime& clipboard& call delete('Xtest_modeless') + new | only! endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0807/src/terminal.c 2020-05-21 20:10:00.281336782 +0200 --- src/terminal.c 2020-05-22 13:31:34.243876336 +0200 *************** *** 3047,3053 **** #endif else { ! term->tl_title = vim_strsave(strval); strval = NULL; } VIM_CLEAR(term->tl_status_text); --- 3047,3053 ---- #endif else { ! term->tl_title = strval; strval = NULL; } VIM_CLEAR(term->tl_status_text); *** ../vim-8.2.0807/src/version.c 2020-05-22 13:09:55.320226061 +0200 --- src/version.c 2020-05-22 13:27:36.908681360 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 808, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// Bram Moolenaar -- b...@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 /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202005221134.04MBYeW9021531%40masaka.moolenaar.net.