• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision357dea6b9fdeff46b3ad6e6d8d204a039f418f4e (tree)
Time2020-05-22 20:45:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.0808: not enough testing for the terminal window

Commit: https://github.com/vim/vim/commit/98f1671cc0ab0ad6139cb9c6ce5262e7f646bc0a
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 22 13:34:01 2020 +0200

patch 8.2.0808: not enough testing for the terminal window
Problem: Not enough testing for the terminal window.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6069) Fix memory
leak.

Change Summary

Incremental Difference

diff -r 6dd44f4380bd -r 357dea6b9fde src/terminal.c
--- a/src/terminal.c Fri May 22 13:15:05 2020 +0200
+++ b/src/terminal.c Fri May 22 13:45:03 2020 +0200
@@ -3047,7 +3047,7 @@
30473047 #endif
30483048 else
30493049 {
3050- term->tl_title = vim_strsave(strval);
3050+ term->tl_title = strval;
30513051 strval = NULL;
30523052 }
30533053 VIM_CLEAR(term->tl_status_text);
diff -r 6dd44f4380bd -r 357dea6b9fde src/testdir/test_gui.vim
--- a/src/testdir/test_gui.vim Fri May 22 13:15:05 2020 +0200
+++ b/src/testdir/test_gui.vim Fri May 22 13:45:03 2020 +0200
@@ -850,8 +850,7 @@
850850 " assume all the other systems have a cat command
851851 let cmd = 'cat'
852852 endif
853- let cmd = ':silent !' . cmd . " test_gui.vim\<CR>\<CR>"
854- call feedkeys(cmd, 'xt')
853+ exe "silent !" . cmd . " test_gui.vim"
855854 " TODO: how to check that the command ran in a separate terminal?
856855 " Maybe check for $TERM (dumb vs xterm) in the spawned shell?
857856 let &guioptions = save_guioptions
diff -r 6dd44f4380bd -r 357dea6b9fde src/testdir/test_terminal.vim
--- a/src/testdir/test_terminal.vim Fri May 22 13:15:05 2020 +0200
+++ b/src/testdir/test_terminal.vim Fri May 22 13:45:03 2020 +0200
@@ -1220,6 +1220,7 @@
12201220 call delete('Xtest.dump')
12211221 call assert_fails("call term_dumpwrite(buf, '')", 'E482:')
12221222 call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:')
1223+ call test_garbagecollect_now()
12231224 call StopVimInTerminal(buf)
12241225 call term_wait(buf)
12251226 call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:')
@@ -1305,6 +1306,16 @@
13051306 call assert_match('three four five', getline(3))
13061307 call assert_match('Undo', getline(45))
13071308 quit
1309+
1310+ " Diff two terminal dump files with different number of rows
1311+ " Swap the diffs
1312+ call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_winline_rnu.dump')
1313+ call assert_match('Test_popup_command_01.dump', getline(21))
1314+ call assert_match('Test_winline_rnu.dump', getline(42))
1315+ normal s
1316+ call assert_match('Test_winline_rnu.dump', getline(6))
1317+ call assert_match('Test_popup_command_01.dump', getline(27))
1318+ quit
13081319 endfunc
13091320
13101321 func Test_terminal_dumpdiff_options()
@@ -1619,6 +1630,7 @@
16191630 call assert_equal(colors, term_getansicolors(buf))
16201631 call StopShellInTerminal(buf)
16211632 call TermWait(buf)
1633+ call assert_equal([], term_getansicolors(buf))
16221634
16231635 exe buf . 'bwipe'
16241636 endfunc
@@ -1673,9 +1685,11 @@
16731685
16741686 let colors[4] = 'Invalid'
16751687 call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
1688+ call assert_fails('call term_setansicolors(buf, {})', 'E714:')
16761689
16771690 call StopShellInTerminal(buf)
16781691 call TermWait(buf)
1692+ call assert_equal(0, term_setansicolors(buf, []))
16791693 exe buf . 'bwipe'
16801694 endfunc
16811695
@@ -2029,7 +2043,7 @@
20292043 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
20302044 call feedkeys("A", 'xt')
20312045 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
2032- call feedkeys("\<C-W>N", 'xt')
2046+ call feedkeys("\<C-\>\<C-N>", 'xt')
20332047 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
20342048 call feedkeys("I", 'xt')
20352049 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
@@ -2066,6 +2080,7 @@
20662080 call term_sendkeys(buf, ":set culopt=line\r")
20672081 call VerifyScreenDump(buf, 'Test_terminal_normal_3', {})
20682082
2083+ call assert_fails('call term_sendkeys(buf, [])', 'E730:')
20692084 call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>")
20702085 call StopVimInTerminal(buf)
20712086 call delete('XtermNormal')
@@ -2178,17 +2193,18 @@
21782193 call StopShellInTerminal(buf)
21792194 endfunc
21802195
2196+" Test for term_gettitle()
21812197 func Test_term_gettitle()
21822198 " term_gettitle() returns an empty string for a non-terminal buffer
21832199 " and for a non-existing buffer.
21842200 call assert_equal('', bufnr('%')->term_gettitle())
21852201 call assert_equal('', term_gettitle(bufnr('$') + 1))
21862202
2187- if !has('title') || &title == 0 || empty(&t_ts)
2203+ if !has('title') || empty(&t_ts)
21882204 throw "Skipped: can't get/set title"
21892205 endif
21902206
2191- let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'])
2207+ let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title'])
21922208 if has('autoservername')
21932209 call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) })
21942210 call term_sendkeys(term, ":e Xfoo\r")
@@ -2692,15 +2708,6 @@
26922708 call assert_equal(output[i], term_getline(buf, 1))
26932709 endfor
26942710
2695- "call term_sendkeys(buf, "\<K0>\<K1>\<K2>\<K3>\<K4>\<K5>\<K6>\<K7>\<K8>\<K9>")
2696- "call term_sendkeys(buf, "\<kEnter>\<kPoint>\<kPlus>")
2697- "call term_sendkeys(buf, "\<kMinus>\<kMultiply>\<kDivide>")
2698- "call term_sendkeys(buf, "\<Esc>")
2699- "call term_sendkeys(buf, "\<Home>\<Ins>\<Tab>\<S-Tab>")
2700- "call term_sendkeys(buf, "\<Esc>")
2701-
2702- "call term_sendkeys(buf, ":write Xkeycodes\<CR>")
2703-
27042711 let keypad_keys = ["\<k0>", "\<k1>", "\<k2>", "\<k3>", "\<k4>", "\<k5>",
27052712 \ "\<k6>", "\<k7>", "\<k8>", "\<k9>", "\<kPoint>", "\<kPlus>",
27062713 \ "\<kMinus>", "\<kMultiply>", "\<kDivide>"]
@@ -2733,7 +2740,6 @@
27332740 let save_term = &term
27342741 let save_ttymouse = &ttymouse
27352742 let save_clipboard = &clipboard
2736- call test_override('no_query_mouse', 1)
27372743 set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard=
27382744
27392745 let lines =<< trim END
@@ -2743,6 +2749,8 @@
27432749 END
27442750 call writefile(lines, 'Xtest_mouse')
27452751
2752+ " Create a terminal window running Vim for the test with mouse enabled
2753+ let prev_win = win_getid()
27462754 let buf = RunVimInTerminal('Xtest_mouse -n', {})
27472755 call term_sendkeys(buf, ":set nocompatible\<CR>")
27482756 call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>")
@@ -2751,6 +2759,12 @@
27512759 call term_wait(buf)
27522760 redraw!
27532761
2762+ " Use the mouse to enter the terminal window
2763+ call win_gotoid(prev_win)
2764+ call feedkeys(MouseLeftClickCode(1, 1), 'x')
2765+ call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
2766+ call assert_equal(1, getwininfo(win_getid())[0].terminal)
2767+
27542768 " Test for <LeftMouse> click/release
27552769 call test_setmouse(2, 5)
27562770 call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt')
@@ -2833,7 +2847,6 @@
28332847 let &ttymouse = save_ttymouse
28342848 let &clipboard = save_clipboard
28352849 set mousetime&
2836- call test_override('no_query_mouse', 0)
28372850 call delete('Xtest_mouse')
28382851 call delete('Xbuf')
28392852 endfunc
@@ -2848,7 +2861,6 @@
28482861 let save_mouse = &mouse
28492862 let save_term = &term
28502863 let save_ttymouse = &ttymouse
2851- call test_override('no_query_mouse', 1)
28522864 set mouse=a term=xterm ttymouse=sgr mousetime=200
28532865 set clipboard=autoselectml
28542866
@@ -2859,12 +2871,21 @@
28592871 END
28602872 call writefile(lines, 'Xtest_modeless')
28612873
2874+ " Create a terminal window running Vim for the test with mouse disabled
2875+ let prev_win = win_getid()
28622876 let buf = RunVimInTerminal('Xtest_modeless -n', {})
28632877 call term_sendkeys(buf, ":set nocompatible\<CR>")
28642878 call term_sendkeys(buf, ":set mouse=\<CR>")
28652879 call term_wait(buf)
28662880 redraw!
28672881
2882+ " Use the mouse to enter the terminal window
2883+ call win_gotoid(prev_win)
2884+ call feedkeys(MouseLeftClickCode(1, 1), 'x')
2885+ call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
2886+ call term_wait(buf)
2887+ call assert_equal(1, getwininfo(win_getid())[0].terminal)
2888+
28682889 " Test for copying a modeless selection to clipboard
28692890 let @* = 'clean'
28702891 " communicating with X server may take a little time
@@ -2881,8 +2902,8 @@
28812902 let &term = save_term
28822903 let &ttymouse = save_ttymouse
28832904 set mousetime& clipboard&
2884- call test_override('no_query_mouse', 0)
28852905 call delete('Xtest_modeless')
2906+ new | only!
28862907 endfunc
28872908
28882909 " vim: shiftwidth=2 sts=2 expandtab
diff -r 6dd44f4380bd -r 357dea6b9fde src/version.c
--- a/src/version.c Fri May 22 13:15:05 2020 +0200
+++ b/src/version.c Fri May 22 13:45:03 2020 +0200
@@ -747,6 +747,8 @@
747747 static int included_patches[] =
748748 { /* Add new patch number below this line */
749749 /**/
750+ 808,
751+/**/
750752 807,
751753 /**/
752754 806,
Show on old repository browser