Mercurial > vim
annotate src/testdir/test_terminal2.vim @ 24851:528e605caece
Added tag v8.2.2963 for changeset f8906bd5b277f421c41d5106c4ced2eb14f4b9ae
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Jun 2021 20:15:06 +0200 |
parents | 5b841f349e77 |
children | a5a772dace5b |
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 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 call writefile(text, 'Xwinsize') |
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 call delete('Xwinsize') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 |
22087
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=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=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
|
41 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
|
42 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 set termwinsize= |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 func Test_terminal_termwinsize_option_zero() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 set termwinsize=0x0 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 let win = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 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
|
51 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 set termwinsize=7x0 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 let win = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 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
|
59 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 set termwinsize=0x33 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 let win = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 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
|
67 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 set termwinsize= |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 func Test_terminal_termwinsize_minimum() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 set termwinsize=10*50 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 vsplit |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 let win = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 resize 15 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 vertical resize 60 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 redraw |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 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
|
87 call assert_equal(15, winheight(win)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 call assert_equal(60, winwidth(win)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 resize 7 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 vertical resize 30 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 redraw |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 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
|
94 call assert_equal(7, winheight(win)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 call assert_equal(30, winwidth(win)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 exe buf . 'bwipe' |
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 set termwinsize=0*0 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 let win = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 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
|
105 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 set termwinsize= |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 |
22079
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 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
|
124 |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 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
|
129 |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
130 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
|
131 endfunc |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
132 |
22097
f369bbd71a53
patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
133 " 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
|
134 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
|
135 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
|
136 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
|
137 let buf = term_start(cmd, #{hidden: 1, term_rows: 10}) |
f369bbd71a53
patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 endfunc |
f369bbd71a53
patch 8.2.1598: starting a hidden terminal resizes the current window
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
142 |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 func Test_terminal_termwinkey() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 " 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
|
145 0tabnew |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 tabnext |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 tabnew |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 tabprev |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 call assert_equal(1, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 call assert_equal(2, tabpagenr()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 let thiswin = win_getid() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 let termwin = bufwinid(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 set termwinkey=<C-L> |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 call feedkeys("\<C-L>w", 'tx') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 call assert_equal(thiswin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 call feedkeys("\<C-W>w", 'tx') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 call assert_equal(termwin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 if has('langmap') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 set langmap=xjyk |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 call feedkeys("\<C-L>x", 'tx') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 call assert_equal(thiswin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 call feedkeys("\<C-W>y", 'tx') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 call assert_equal(termwin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 set langmap= |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 call feedkeys("\<C-L>gt", "xt") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 call assert_equal(3, tabpagenr()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 tabprev |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 call assert_equal(2, tabpagenr()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 call assert_equal(termwin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 call feedkeys("\<C-L>gT", "xt") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 call assert_equal(1, tabpagenr()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 tabnext |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 call assert_equal(2, tabpagenr()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 call assert_equal(termwin, win_getid()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 let job = term_getjob(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 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
|
184 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
|
185 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 set termwinkey& |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 tabnext |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 tabclose |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 tabprev |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 tabclose |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 func Test_terminal_out_err() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 CheckUnix |
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 call writefile([ |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 \ '#!/bin/sh', |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 \ 'echo "this is standard error" >&2', |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 \ 'echo "this is standard out" >&1', |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 \ ], 'Xechoerrout.sh') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 call setfperm('Xechoerrout.sh', 'rwxrwx---') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 let outfile = 'Xtermstdout' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 let buf = term_start(['./Xechoerrout.sh'], {'out_io': 'file', 'out_name': outfile}) |
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 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
|
207 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
|
208 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
|
209 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 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
|
211 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 call delete('Xechoerrout.sh') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 call delete(outfile) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 func Test_termwinscroll() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 CheckUnix |
21257
34a0f73226d9
patch 8.2.1179: Test_termwinscroll() sometimes hangs in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21253
diff
changeset
|
218 " 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
|
219 CheckNotGui |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 " 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
|
222 " will be dropped. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 exe 'set termwinscroll=' . &lines |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 let buf = term_start('/bin/sh') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 for i in range(1, &lines) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 call feedkeys("echo " . i . "\<CR>", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 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
|
228 endfor |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 " 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
|
230 call feedkeys("\<C-W>N", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 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
|
232 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 " 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
|
234 let lines = getline(1, line('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 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
|
236 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
|
237 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
|
238 endfor |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 exe buf . 'bwipe!' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 " 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
|
244 " TODO: This does not reproduce the original problem. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 func Test_terminal_resize() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 set statusline=x |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 terminal |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 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
|
249 let buf = bufnr() |
5b841f349e77
patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
250 |
5b841f349e77
patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
251 " 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
|
252 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
|
253 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 " Fill the terminal with text. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 if has('win32') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 call feedkeys("dir\<CR>", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 else |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 call feedkeys("ls\<CR>", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 endif |
24214
5b841f349e77
patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
260 " Wait for some output |
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, 3))}) |
5b841f349e77
patch 8.2.2648: terminal resize test sometimes hangs
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
262 |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 " 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
|
264 call feedkeys("\<C-W>N", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 " Open a new window |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 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
|
267 call assert_equal(3, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 redraw |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 close |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 call assert_equal(2, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 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
|
273 call TermWait(buf) |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 set statusline& |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 " 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
|
278 func Test_zz1_terminal_in_gui() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 CheckCanRunGui |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 " 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
|
282 call test_ignore_error('E285:') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 gui -f |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 call assert_equal(1, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 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
|
288 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 " 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
|
292 call WaitForAssert({-> assert_equal(1, winnr('$'))}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 call assert_equal("", bufname(buf)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 unlet g:job |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
22405
diff
changeset
|
298 " TODO: re-enable when this no longer hangs on Travis |
21273
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
299 "func Test_zz2_terminal_guioptions_bang() |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
300 " CheckGui |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
301 " set guioptions+=! |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
302 " |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
303 " let filename = 'Xtestscript' |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
304 " if has('win32') |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
305 " let filename .= '.bat' |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
306 " let prefix = '' |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
307 " let contents = ['@echo off', 'exit %1'] |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
308 " else |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
309 " let filename .= '.sh' |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
310 " let prefix = './' |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
311 " let contents = ['#!/bin/sh', 'exit $1'] |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
312 " endif |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
313 " call writefile(contents, filename) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
314 " call setfperm(filename, 'rwxrwx---') |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
315 " |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
316 " " Check if v:shell_error is equal to the exit status. |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
317 " let exitval = 0 |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
318 " execute printf(':!%s%s %d', prefix, filename, exitval) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
319 " call assert_equal(exitval, v:shell_error) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
320 " |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
321 " let exitval = 9 |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
322 " execute printf(':!%s%s %d', prefix, filename, exitval) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
323 " call assert_equal(exitval, v:shell_error) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
324 " |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
325 " set guioptions& |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
326 " call delete(filename) |
c02041a2b66a
patch 8.2.1187: terminal2 test sometimes hangs in the GUI on Travis
Bram Moolenaar <Bram@vim.org>
parents:
21257
diff
changeset
|
327 "endfunc |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 func Test_terminal_hidden() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 CheckUnix |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 term ++hidden cat |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 let bnr = bufnr('$') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 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
|
335 exe 'sbuf ' . bnr |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 call assert_equal('terminal', &buftype) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 call term_sendkeys(bnr, "asdf\<CR>") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 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
|
339 call term_sendkeys(bnr, "\<C-D>") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 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
|
341 bwipe! |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 func Test_terminal_switch_mode() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 term |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 let bnr = bufnr('$') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 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
|
348 " 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
|
349 " 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
|
350 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
|
351 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
|
352 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
|
353 call feedkeys("\<C-W>N", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 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
|
355 call feedkeys("A", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 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
|
357 call feedkeys("\<C-\>\<C-N>", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 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
|
359 call feedkeys("I", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 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
|
361 call feedkeys("\<C-W>Nv", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 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
|
363 call feedkeys("I", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 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
|
365 call feedkeys("\<C-W>Nv", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 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
|
367 call feedkeys("A", 'xt') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 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
|
369 bwipe! |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 func Test_terminal_normal_mode() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 CheckRunVimInTerminal |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 " 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
|
376 let lines =<< trim END |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 call setline(1, range(11111, 11122)) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 3 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 END |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 call writefile(lines, 'XtermNormal') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 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
|
382 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 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
|
385 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
|
386 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
|
387 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 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
|
389 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
|
390 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 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
|
392 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
|
393 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 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
|
395 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
|
396 call StopVimInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 call delete('XtermNormal') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 func Test_terminal_hidden_and_close() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 CheckUnix |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 call assert_equal(1, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 term ++hidden ++close ls |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 let bnr = bufnr('$') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 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
|
407 call WaitForAssert({-> assert_false(bufexists(bnr))}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 call assert_equal(1, winnr('$')) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 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
|
412 if has('conpty') |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21295
diff
changeset
|
413 throw 'Skipped: fail on ConPTY' |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 let contents = [ |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 \ [ 'One', '', 'X' ], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 \ [ 'Two', '', '' ], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 \ [ 'Three' ] + repeat([''], 30) |
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 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 for c in contents |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 call writefile(c, 'Xfile') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 if has('win32') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 term cmd /c type Xfile |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 else |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 term cat Xfile |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 let bnr = bufnr('$') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 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
|
430 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
|
431 sleep 100m |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 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
|
433 quit |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 endfor |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 call delete('Xfile') |
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 |
22079
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
439 func GetDummyCmd() |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 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
|
441 return 'cmd /c ""' |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 else |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 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
|
444 return 'false' |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 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
|
446 endfunc |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
447 |
ba2c3f38a596
patch 8.2.1589: term_start() options for size are overruled by 'termwinsize'
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
448 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
|
449 let cmd = GetDummyCmd() |
21126
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 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
|
451 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
|
452 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 func Test_term_getcursor() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 CheckUnix |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 " 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
|
460 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
|
461 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 " Hide the cursor. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 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
|
464 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
|
465 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 " Show the cursor. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 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
|
468 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
|
469 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 " Change color of cursor. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 " Make cursor a blinking block. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 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
|
479 call WaitForAssert({-> assert_equal([1, 1], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 \ [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
|
481 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 " Make cursor a steady block. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 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
|
484 call WaitForAssert({-> assert_equal([0, 1], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 \ [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
|
486 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 " Make cursor a blinking underline. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 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
|
489 call WaitForAssert({-> assert_equal([1, 2], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 \ [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
|
491 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 " Make cursor a steady underline. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 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
|
494 call WaitForAssert({-> assert_equal([0, 2], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 \ [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
|
496 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 " Make cursor a blinking vertical bar. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 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
|
499 call WaitForAssert({-> assert_equal([1, 3], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 \ [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
|
501 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 " Make cursor a steady vertical bar. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 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
|
504 call WaitForAssert({-> assert_equal([0, 3], |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 \ [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
|
506 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 " Test for term_gettitle() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 func Test_term_gettitle() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 " 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
|
513 " and for a non-existing buffer. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 call assert_equal('', bufnr('%')->term_gettitle()) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 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
|
516 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 if !has('title') || empty(&t_ts) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 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
|
519 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title']) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 if has('autoservername') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) }) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 call term_sendkeys(term, ":e Xfoo\r") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 call WaitForAssert({-> assert_match('^Xfoo (.*[/\\]testdir) - VIM\d\+$', term_gettitle(term)) }) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 else |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 call WaitForAssert({-> assert_equal('[No Name] - VIM', term_gettitle(term)) }) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 call term_sendkeys(term, ":e Xfoo\r") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 call WaitForAssert({-> assert_match('^Xfoo (.*[/\\]testdir) - VIM$', term_gettitle(term)) }) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 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
|
533 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
|
534 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 exe term . 'bwipe!' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 func Test_term_gettty() |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 let buf = Run_shell_in_terminal({}) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 let gettty = term_gettty(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 if has('unix') && executable('tty') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 " 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
|
544 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
|
545 call term_sendkeys(buf, "tty\r") |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 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
|
547 let tty = term_getline(buf, 2) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 call assert_equal(tty, gettty) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 let gettty0 = term_gettty(buf, 0) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 let gettty1 = term_gettty(buf, 1) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 call assert_equal(gettty, gettty0) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 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
|
556 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
|
557 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 if has('unix') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 " 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
|
560 " 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
|
561 call assert_equal(gettty0, gettty1) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 call assert_match('^/dev/', gettty) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 else |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 " ConPTY works on anonymous pipe. |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 if !has('conpty') |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 call assert_match('^\\\\.\\pipe\\', gettty0) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 call assert_match('^\\\\.\\pipe\\', gettty1) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 endif |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 |
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
|
571 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
|
572 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
|
573 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 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
|
575 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 call StopShellInTerminal(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 call TermWait(buf) |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 exe buf . 'bwipe' |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 endfunc |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 |
a35036006352
patch 8.2.1114: terminal test sometimes times out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 " vim: shiftwidth=2 sts=2 expandtab |