annotate src/testdir/test_terminal2.vim @ 27936:07aea9530e05 v8.2.4493

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