annotate src/testdir/test_terminal2.vim @ 35466:9982c22412af v9.1.0502

patch 9.1.0502: MS-Windows: too much legacy code Commit: https://github.com/vim/vim/commit/56f587b3f81f403bb0546c6892b3273b2a9e954f Author: K.Takata <kentkt@csc.jp> Date: Wed Jun 19 19:56:03 2024 +0200 patch 9.1.0502: MS-Windows: too much legacy code Problem: MS-Windows: too much legacy code Solution: Clean up old code (Ken Takata) * Remove very old codes for Cygwin version of GCC. Nowadays Cygwin GCC cannot be used for building Win32 Vim. (The `-mno-cygwin` option was removed in Cygwin GCC4.) * Remove old codes for old versions of MinGW. Remove `__MINGW32__` as much as possible. * Adjust makefile. closes: #15044 Signed-off-by: K.Takata <kentkt@csc.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 19 Jun 2024 20:00:09 +0200
parents 74e92770d59e
children 1ee567e88a22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for the terminal window.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " This is split in two, because it can take a lot of time.
21253
ffa6b82fa993 patch 8.2.1177: terminal2 test sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 21126
diff changeset
3 " See test_terminal.vim and test_terminal3.vim for further tests.
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 source check.vim
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 CheckFeature terminal
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 source shared.vim
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 source screendump.vim
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 source mouse.vim
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 source term_util.vim
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let $PROMPT_COMMAND=''
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 func Test_terminal_termwinsize_option_fixed()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 CheckRunVimInTerminal
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 set termwinsize=6x40
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 let text = []
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 for n in range(10)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call add(text, repeat(n, 50))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 endfor
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
22 call writefile(text, 'Xwinsize', 'D')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 let buf = RunVimInTerminal('Xwinsize', {})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call assert_equal([6, 40], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 call assert_equal(6, winheight(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call assert_equal(40, winwidth(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 " resizing the window doesn't resize the terminal.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 resize 10
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 vertical resize 60
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 call assert_equal([6, 40], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 call assert_equal(10, winheight(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call assert_equal(60, winwidth(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call StopVimInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 22079
diff changeset
38 call assert_fails('set termwinsize=40', 'E474:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 22079
diff changeset
39 call assert_fails('set termwinsize=10+40', 'E474:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 22079
diff changeset
40 call assert_fails('set termwinsize=abc', 'E474:')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 set termwinsize=
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 func Test_terminal_termwinsize_option_zero()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 set termwinsize=0x0
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 set termwinsize=7x0
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 call assert_equal([7, winwidth(win)], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 set termwinsize=0x33
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call assert_equal([winheight(win), 33], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
33301
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
67 " This used to crash Vim
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
68 set termwinsize=10000*10000
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
69 let buf = Run_shell_in_terminal({})
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
70 let win = bufwinid(buf)
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
71 call assert_equal([1000, 1000], term_getsize(buf))
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
72 call StopShellInTerminal(buf)
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
73 exe buf . 'bwipe'
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
74
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 set termwinsize=
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 func Test_terminal_termwinsize_minimum()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 set termwinsize=10*50
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 vsplit
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 call assert_inrange(10, 1000, winheight(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 call assert_inrange(50, 1000, winwidth(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 resize 15
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 vertical resize 60
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 redraw
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 call assert_equal([15, 60], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call assert_equal(15, winheight(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 call assert_equal(60, winwidth(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 resize 7
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 vertical resize 30
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 redraw
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 call assert_equal([10, 50], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 call assert_equal(7, winheight(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 call assert_equal(30, winwidth(win))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 set termwinsize=0*0
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 let win = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 set termwinsize=
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113
22079
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
114 func Test_terminal_termwinsize_overruled()
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
115 let cmd = GetDummyCmd()
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
116 set termwinsize=5x43
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
117 let buf = term_start(cmd, #{term_rows: 7, term_cols: 50})
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
118 call TermWait(buf)
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
119 call assert_equal([7, 50], term_getsize(buf))
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
120 exe "bwipe! " .. buf
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
121
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
122 let buf = term_start(cmd, #{term_cols: 50})
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
123 call TermWait(buf)
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
124 call assert_equal([5, 50], term_getsize(buf))
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
125 exe "bwipe! " .. buf
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
126
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
127 let buf = term_start(cmd, #{term_rows: 7})
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
128 call TermWait(buf)
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
129 call assert_equal([7, 43], term_getsize(buf))
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
130 exe "bwipe! " .. buf
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
131
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
132 set termwinsize=
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
133 endfunc
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
134
22097
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
135 " hidden terminal must not change current window size
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
136 func Test_terminal_hidden_winsize()
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
137 let cmd = GetDummyCmd()
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
138 let rows = winheight(0)
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
139 let buf = term_start(cmd, #{hidden: 1, term_rows: 10})
31780
8f15c56ff2fb patch 9.0.1222: terminal tests are flaky on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
140 call TermWait(buf)
22097
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
141 call assert_equal(rows, winheight(0))
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
142 call assert_equal([10, &columns], term_getsize(buf))
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
143 exe "bwipe! " .. buf
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
144 endfunc
f369bbd71a53 patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
145
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 func Test_terminal_termwinkey()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 " make three tabpages, terminal in the middle
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 0tabnew
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 tabnext
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 tabnew
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 tabprev
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 call assert_equal(1, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 call assert_equal(2, tabpagenr())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 let thiswin = win_getid()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 let termwin = bufwinid(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 set termwinkey=<C-L>
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 call feedkeys("\<C-L>w", 'tx')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 call assert_equal(thiswin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 call feedkeys("\<C-W>w", 'tx')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 call assert_equal(termwin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 if has('langmap')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 set langmap=xjyk
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 call feedkeys("\<C-L>x", 'tx')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 call assert_equal(thiswin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 call feedkeys("\<C-W>y", 'tx')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 call assert_equal(termwin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 set langmap=
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 endif
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 call feedkeys("\<C-L>gt", "xt")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 call assert_equal(3, tabpagenr())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 tabprev
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 call assert_equal(2, tabpagenr())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 call assert_equal(termwin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 call feedkeys("\<C-L>gT", "xt")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 call assert_equal(1, tabpagenr())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 tabnext
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 call assert_equal(2, tabpagenr())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 call assert_equal(termwin, win_getid())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 let job = term_getjob(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 call feedkeys("\<C-L>\<C-C>", 'tx')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 call WaitForAssert({-> assert_equal("dead", job_status(job))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 set termwinkey&
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 tabnext
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 tabclose
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 tabprev
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 tabclose
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 func Test_terminal_out_err()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 CheckUnix
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 call writefile([
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 \ '#!/bin/sh',
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 \ 'echo "this is standard error" >&2',
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 \ 'echo "this is standard out" >&1',
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
203 \ ], 'Xechoerrout.sh', 'D')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 call setfperm('Xechoerrout.sh', 'rwxrwx---')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 let outfile = 'Xtermstdout'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 let buf = term_start(['./Xechoerrout.sh'], {'out_io': 'file', 'out_name': outfile})
31780
8f15c56ff2fb patch 9.0.1222: terminal tests are flaky on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
208 call TermWait(buf)
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 call WaitFor({-> !empty(readfile(outfile)) && !empty(term_getline(buf, 1))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 call assert_equal(['this is standard out'], readfile(outfile))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 call assert_equal('this is standard error', term_getline(buf, 1))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 call delete(outfile)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 func Test_termwinscroll()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 CheckUnix
21257
34a0f73226d9 patch 8.2.1179: Test_termwinscroll() sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
221 " TODO: Somehow this test sometimes hangs in the GUI
34a0f73226d9 patch 8.2.1179: Test_termwinscroll() sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 21253
diff changeset
222 CheckNotGui
25969
a5a772dace5b patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 24214
diff changeset
223 let g:test_is_flaky = 1
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 " Let the terminal output more than 'termwinscroll' lines, some at the start
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 " will be dropped.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 exe 'set termwinscroll=' . &lines
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 let buf = term_start('/bin/sh')
31780
8f15c56ff2fb patch 9.0.1222: terminal tests are flaky on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
229 call TermWait(buf)
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 for i in range(1, &lines)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 call feedkeys("echo " . i . "\<CR>", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 call WaitForAssert({-> assert_match(string(i), term_getline(buf, term_getcursor(buf)[0] - 1))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 endfor
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 " Go to Terminal-Normal mode to update the buffer.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 call feedkeys("\<C-W>N", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 call assert_inrange(&lines, &lines * 110 / 100 + winheight(0), line('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 " Every "echo nr" must only appear once
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 let lines = getline(1, line('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 for i in range(&lines - len(lines) / 2 + 2, &lines)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 let filtered = filter(copy(lines), {idx, val -> val =~ 'echo ' . i . '\>'})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 call assert_equal(1, len(filtered), 'for "echo ' . i . '"')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 endfor
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 exe buf . 'bwipe!'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 " Resizing the terminal window caused an ml_get error.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 " TODO: This does not reproduce the original problem.
33858
af382e6903ac CI: disable the test_terminal_resize() test for GH CI in GUI (#13603)
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
250 " TODO: This test starts timing out in Github CI Gui test, why????
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 func Test_terminal_resize()
33858
af382e6903ac CI: disable the test_terminal_resize() test for GH CI in GUI (#13603)
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
252 if has('gui_running') && expand('$GITHUB_ACTIONS') ==# 'true'
af382e6903ac CI: disable the test_terminal_resize() test for GH CI in GUI (#13603)
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
253 throw 'Skipped: FIXME: this test times-out in Github Actions CI with GUI. Why?'
af382e6903ac CI: disable the test_terminal_resize() test for GH CI in GUI (#13603)
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
254 endif
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 set statusline=x
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 terminal
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 call assert_equal(2, winnr('$'))
24214
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
258 let buf = bufnr()
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
259
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
260 " Wait for the shell to display a prompt
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
261 call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 " Fill the terminal with text.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 if has('win32')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 call feedkeys("dir\<CR>", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 else
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 call feedkeys("ls\<CR>", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 endif
24214
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
269 " Wait for some output
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
270 call WaitForAssert({-> assert_notequal('', term_getline(buf, 3))})
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
271
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 " Go to Terminal-Normal mode for a moment.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 call feedkeys("\<C-W>N", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 " Open a new window
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 call feedkeys("i\<C-W>n", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 call assert_equal(3, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 redraw
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 close
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 call assert_equal(2, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 call feedkeys("exit\<CR>", 'xt')
24214
5b841f349e77 patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
282 call TermWait(buf)
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 set statusline&
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285
33867
c80400d7f7fe CI: disable the test_terminal_resize2() test for GH CI in gui mode (#13615)
Christian Brabandt <cb@256bit.org>
parents: 33858
diff changeset
286 " TODO: This test starts timing out in Github CI Gui test, why????
33301
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
287 func Test_terminal_resize2()
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
288 CheckNotMSWindows
33867
c80400d7f7fe CI: disable the test_terminal_resize2() test for GH CI in gui mode (#13615)
Christian Brabandt <cb@256bit.org>
parents: 33858
diff changeset
289 if has('gui_running') && expand('$GITHUB_ACTIONS') ==# 'true'
c80400d7f7fe CI: disable the test_terminal_resize2() test for GH CI in gui mode (#13615)
Christian Brabandt <cb@256bit.org>
parents: 33858
diff changeset
290 throw 'Skipped: FIXME: this test times-out in Github Actions CI with GUI. Why?'
c80400d7f7fe CI: disable the test_terminal_resize2() test for GH CI in gui mode (#13615)
Christian Brabandt <cb@256bit.org>
parents: 33858
diff changeset
291 endif
33301
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
292 set statusline=x
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
293 terminal
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
294 call assert_equal(2, winnr('$'))
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
295 let buf = bufnr()
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
296
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
297 " Wait for the shell to display a prompt
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
298 call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
299
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
300 " This used to crash Vim
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
301 call feedkeys("printf '\033[8;99999;99999t'\<CR>", 'xt')
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
302 redraw
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
303
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
304 call feedkeys("exit\<CR>", 'xt')
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
305 call TermWait(buf)
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
306 set statusline&
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
307 endfunc
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 31780
diff changeset
308
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 " must be nearly the last, we can't go back from GUI to terminal
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 func Test_zz1_terminal_in_gui()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 CheckCanRunGui
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 " Ignore the "failed to create input context" error.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 call test_ignore_error('E285:')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 gui -f
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 call assert_equal(1, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 let buf = Run_shell_in_terminal({'term_finish': 'close'})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 " closing window wipes out the terminal buffer a with finished job
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 call WaitForAssert({-> assert_equal(1, winnr('$'))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 call assert_equal("", bufname(buf))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 unlet g:job
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
329 func Test_zz2_terminal_guioptions_bang()
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
330 CheckGui
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
331 set guioptions+=!
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
332
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
333 let filename = 'Xtestscript'
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
334 if has('win32')
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
335 let filename .= '.bat'
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
336 let prefix = ''
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
337 let contents = ['@echo off', 'exit %1']
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
338 else
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
339 let filename .= '.sh'
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
340 let prefix = './'
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
341 let contents = ['#!/bin/sh', 'exit $1']
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
342 endif
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
343 call writefile(contents, filename, 'D')
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
344 call setfperm(filename, 'rwxrwx---')
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
345
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
346 " Check if v:shell_error is equal to the exit status.
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
347 let exitval = 0
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
348 execute printf(':!%s%s %d', prefix, filename, exitval)
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
349 call assert_equal(exitval, v:shell_error)
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
350
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
351 let exitval = 9
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
352 execute printf(':!%s%s %d', prefix, filename, exitval)
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
353 call assert_equal(exitval, v:shell_error)
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
354
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
355 set guioptions&
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
356 endfunc
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 func Test_terminal_hidden()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 CheckUnix
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 term ++hidden cat
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 let bnr = bufnr('$')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 call assert_equal('terminal', getbufvar(bnr, '&buftype'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 exe 'sbuf ' . bnr
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 call assert_equal('terminal', &buftype)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 call term_sendkeys(bnr, "asdf\<CR>")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 call WaitForAssert({-> assert_match('asdf', term_getline(bnr, 2))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 call term_sendkeys(bnr, "\<C-D>")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 call WaitForAssert({-> assert_equal('finished', bnr->term_getstatus())})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 bwipe!
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 func Test_terminal_switch_mode()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 term
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 let bnr = bufnr('$')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
21273
c02041a2b66a patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21257
diff changeset
377 " In the GUI the first switch sometimes doesn't work. Switch twice to avoid
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22405
diff changeset
378 " flakiness.
21273
c02041a2b66a patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21257
diff changeset
379 call feedkeys("\<C-W>N", 'xt')
c02041a2b66a patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21257
diff changeset
380 call feedkeys("A", 'xt')
c02041a2b66a patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents: 21257
diff changeset
381 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 call feedkeys("\<C-W>N", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 call feedkeys("A", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 call feedkeys("\<C-\>\<C-N>", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 call feedkeys("I", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 call feedkeys("\<C-W>Nv", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 call feedkeys("I", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 call feedkeys("\<C-W>Nv", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 call feedkeys("A", 'xt')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 bwipe!
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 func Test_terminal_normal_mode()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 CheckRunVimInTerminal
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 " Run Vim in a terminal and open a terminal window to run Vim in.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 let lines =<< trim END
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 call setline(1, range(11111, 11122))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 3
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 END
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
409 call writefile(lines, 'XtermNormal', 'D')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 let buf = RunVimInTerminal('-S XtermNormal', {'rows': 8})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 call TermWait(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 call term_sendkeys(buf, "\<C-W>N")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 call term_sendkeys(buf, ":set number cursorline culopt=both\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 call VerifyScreenDump(buf, 'Test_terminal_normal_1', {})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 call term_sendkeys(buf, ":set culopt=number\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 call VerifyScreenDump(buf, 'Test_terminal_normal_2', {})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 call term_sendkeys(buf, ":set culopt=line\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 call VerifyScreenDump(buf, 'Test_terminal_normal_3', {})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 call assert_fails('call term_sendkeys(buf, [])', 'E730:')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 call StopVimInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 func Test_terminal_hidden_and_close()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 CheckUnix
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 call assert_equal(1, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 term ++hidden ++close ls
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 let bnr = bufnr('$')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 call assert_equal('terminal', getbufvar(bnr, '&buftype'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 call WaitForAssert({-> assert_false(bufexists(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 call assert_equal(1, winnr('$'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 func Test_terminal_does_not_truncate_last_newlines()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 if has('conpty')
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21295
diff changeset
441 throw 'Skipped: fail on ConPTY'
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 endif
25969
a5a772dace5b patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 24214
diff changeset
443 let g:test_is_flaky = 1
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 let contents = [
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 \ [ 'One', '', 'X' ],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 \ [ 'Two', '', '' ],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 \ [ 'Three' ] + repeat([''], 30)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 \ ]
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 for c in contents
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
451 call writefile(c, 'Xdntfile', 'D')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 if has('win32')
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
453 term cmd /c type Xdntfile
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 else
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
455 term cat Xdntfile
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 endif
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 let bnr = bufnr('$')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 call assert_equal('terminal', getbufvar(bnr, '&buftype'))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 call WaitForAssert({-> assert_equal('finished', term_getstatus(bnr))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 sleep 100m
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 call assert_equal(c, getline(1, line('$')))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 quit
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 endfor
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465
22079
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
466 func GetDummyCmd()
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 if has('win32')
22079
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
468 return 'cmd /c ""'
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 else
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 CheckExecutable false
22079
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
471 return 'false'
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 endif
22079
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
473 endfunc
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
474
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
475 func Test_terminal_no_job()
ba2c3f38a596 patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
476 let cmd = GetDummyCmd()
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 let term = term_start(cmd, {'term_finish': 'close'})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) })
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 func Test_term_getcursor()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 CheckUnix
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 " Wait for the shell to display a prompt.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 " Hide the cursor.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 call term_sendkeys(buf, "echo -e '\\033[?25l'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 call WaitForAssert({-> assert_equal(0, term_getcursor(buf)[2].visible)})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 " Show the cursor.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 call term_sendkeys(buf, "echo -e '\\033[?25h'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 call WaitForAssert({-> assert_equal(1, buf->term_getcursor()[2].visible)})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 " Change color of cursor.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 call term_sendkeys(buf, "echo -e '\\033]12;blue\\007'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 call WaitForAssert({-> assert_equal('blue', term_getcursor(buf)[2].color)})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 call term_sendkeys(buf, "echo -e '\\033]12;green\\007'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 call WaitForAssert({-> assert_equal('green', term_getcursor(buf)[2].color)})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 " Make cursor a blinking block.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 call term_sendkeys(buf, "echo -e '\\033[1 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 call WaitForAssert({-> assert_equal([1, 1],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 " Make cursor a steady block.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 call term_sendkeys(buf, "echo -e '\\033[2 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 call WaitForAssert({-> assert_equal([0, 1],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 " Make cursor a blinking underline.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 call term_sendkeys(buf, "echo -e '\\033[3 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 call WaitForAssert({-> assert_equal([1, 2],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 " Make cursor a steady underline.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 call term_sendkeys(buf, "echo -e '\\033[4 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 call WaitForAssert({-> assert_equal([0, 2],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 " Make cursor a blinking vertical bar.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 call term_sendkeys(buf, "echo -e '\\033[5 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 call WaitForAssert({-> assert_equal([1, 3],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 " Make cursor a steady vertical bar.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 call term_sendkeys(buf, "echo -e '\\033[6 q'\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 call WaitForAssert({-> assert_equal([0, 3],
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 " Test for term_gettitle()
34422
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
538 " Known to be flaky on Mac-OS X and the GH runners
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 func Test_term_gettitle()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 " term_gettitle() returns an empty string for a non-terminal buffer
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 " and for a non-existing buffer.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 call assert_equal('', bufnr('%')->term_gettitle())
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 call assert_equal('', term_gettitle(bufnr('$') + 1))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 if !has('title') || empty(&t_ts)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 throw "Skipped: can't get/set title"
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 endif
34422
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
548 if has('osx') && !empty($CI) && system('uname -m') =~# 'arm64'
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
549 " This test often fails with the following error message on Github runners
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
550 " MacOS-14
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
551 " '^\\[No Name\\] - VIM\\d*$' does not match 'e] - VIM'
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
552 " Why? Is the terminal that runs Vim too small?
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
553 throw 'Skipped: FIXME: Running this test on M1 Mac fails on GitHub Actions'
74e92770d59e patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Christian Brabandt <cb@256bit.org>
parents: 34349
diff changeset
554 endif
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title'])
31780
8f15c56ff2fb patch 9.0.1222: terminal tests are flaky on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
557 call TermWait(term)
26522
c6a57c46271e patch 8.2.3790: test for term_gettitle() fails in some environments
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
558 " When Vim is running as a server then the title ends in VIM{number}, thus
c6a57c46271e patch 8.2.3790: test for term_gettitle() fails in some environments
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
559 " optionally match a number after "VIM".
c6a57c46271e patch 8.2.3790: test for term_gettitle() fails in some environments
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
560 call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d*$', term_gettitle(term)) })
c6a57c46271e patch 8.2.3790: test for term_gettitle() fails in some environments
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
561 call term_sendkeys(term, ":e Xfoo\r")
c6a57c46271e patch 8.2.3790: test for term_gettitle() fails in some environments
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
562 call WaitForAssert({-> assert_match('^Xfoo (.*[/\\]testdir) - VIM\d*$', term_gettitle(term)) })
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 call term_sendkeys(term, ":set titlestring=foo\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 call WaitForAssert({-> assert_equal('foo', term_gettitle(term)) })
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 exe term . 'bwipe!'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 func Test_term_gettty()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 let buf = Run_shell_in_terminal({})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 let gettty = term_gettty(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 if has('unix') && executable('tty')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 " Find tty using the tty shell command.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 call term_sendkeys(buf, "tty\r")
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 call WaitForAssert({-> assert_notequal('', term_getline(buf, 3))})
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 let tty = term_getline(buf, 2)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 call assert_equal(tty, gettty)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 endif
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 let gettty0 = term_gettty(buf, 0)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 let gettty1 = term_gettty(buf, 1)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 call assert_equal(gettty, gettty0)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 call assert_equal(job_info(g:job).tty_out, gettty0)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 call assert_equal(job_info(g:job).tty_in, gettty1)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 if has('unix')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 " For unix, term_gettty(..., 0) and term_gettty(..., 1)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 " are identical according to :help term_gettty()
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 call assert_equal(gettty0, gettty1)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 call assert_match('^/dev/', gettty)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 else
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 " ConPTY works on anonymous pipe.
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 if !has('conpty')
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 call assert_match('^\\\\.\\pipe\\', gettty0)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 call assert_match('^\\\\.\\pipe\\', gettty1)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 endif
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 endif
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602
22405
0ef3ae4ec70e patch 8.2.1751: using 2 where bool is expected may throw an error
Bram Moolenaar <Bram@vim.org>
parents: 22161
diff changeset
603 call assert_fails('call term_gettty(buf, 2)', 'E475:')
0ef3ae4ec70e patch 8.2.1751: using 2 where bool is expected may throw an error
Bram Moolenaar <Bram@vim.org>
parents: 22161
diff changeset
604 call assert_fails('call term_gettty(buf, -1)', 'E475:')
21126
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 call assert_equal('', term_gettty(buf + 1))
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 call StopShellInTerminal(buf)
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 exe buf . 'bwipe'
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 endfunc
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612
a35036006352 patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 " vim: shiftwidth=2 sts=2 expandtab