annotate src/testdir/test_suspend.vim @ 32762:6ee6de3bbc94 v9.0.1700

patch 9.0.1700: Cannot compile with dynamic perl < 5.38 Commit: https://github.com/vim/vim/commit/32f586eec1a48784566f8e7aad5cab0ad6105b02 Author: K.Takata <kentkt@csc.jp> Date: Sun Aug 13 10:15:05 2023 +0200 patch 9.0.1700: Cannot compile with dynamic perl < 5.38 Problem: Cannot compile with dynamic perl < 5.38 (after 9.0.1681) Solution: Fix if_perl/dyn from perl 5.32 to 5.38 closes: #12755 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: K.Takata <kentkt@csc.jp>
author Christian Brabandt <cb@256bit.org>
date Sun, 13 Aug 2023 10:30:05 +0200
parents 543cb94c6c09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test :suspend
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
3 source check.vim
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 16336
diff changeset
4 source term_util.vim
31341
3071d91e52f0 patch 9.0.1004: suspend test sometimes fails on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 23165
diff changeset
5 source shared.vim
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
16336
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
7 func CheckSuspended(buf, fileExists)
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
8 call WaitForAssert({-> assert_match('[$#] $', term_getline(a:buf, '.'))})
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
9
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
10 if a:fileExists
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
11 call assert_equal(['foo'], readfile('Xfoo'))
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
12 else
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
13 " Without 'autowrite', buffer should not be written.
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
14 call assert_equal(0, filereadable('Xfoo'))
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
15 endif
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
16
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
17 call term_sendkeys(a:buf, "fg\<CR>\<C-L>")
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
18 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(a:buf, '.'))})
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
19 endfunc
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
20
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 func Test_suspend()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
22 CheckFeature terminal
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
23 CheckExecutable /bin/sh
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
31369
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
25 " Somehow the modifyOtherKeys response may get to the terminal when using
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
26 " Mac OS. Make t_RK and 'keyprotocol' empty to avoid that.
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
27 set t_RK= keyprotocol=
31359
adb96415b5b7 patch 9.0.1013: suspend test often fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31347
diff changeset
28
31341
3071d91e52f0 patch 9.0.1004: suspend test sometimes fails on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 23165
diff changeset
29 call WaitForResponses()
3071d91e52f0 patch 9.0.1004: suspend test sometimes fails on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 23165
diff changeset
30
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let buf = term_start('/bin/sh')
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " Wait for shell prompt.
14993
4234c348aa90 patch 8.1.0508: suspend test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents: 14832
diff changeset
33 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
17700
97b859062d67 patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
35 call term_sendkeys(buf, v:progpath
97b859062d67 patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
36 \ . " --clean -X"
31377
543cb94c6c09 patch 9.0.1022: suspend test fails on Mac OS when suspending Vim
Bram Moolenaar <Bram@vim.org>
parents: 31369
diff changeset
37 \ . " -c 'set nu keyprotocol='"
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 \ . " -c 'call setline(1, \"foo\")'"
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 \ . " Xfoo\<CR>")
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " Cursor in terminal buffer should be on first line in spawned vim.
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))})
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 for suspend_cmd in [":suspend\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 \ ":stop\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 \ ":suspend!\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 \ ":stop!\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 \ "\<C-Z>"]
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " Suspend and wait for shell prompt.
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call term_sendkeys(buf, suspend_cmd)
16336
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
50 call CheckSuspended(buf, 0)
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endfor
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Test that :suspend! with 'autowrite' writes content of buffers if modified.
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call term_sendkeys(buf, ":set autowrite\<CR>")
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal(0, filereadable('Xfoo'))
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call term_sendkeys(buf, ":suspend\<CR>")
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Wait for shell prompt.
16336
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
58 call CheckSuspended(buf, 1)
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59
15523
47328ce4b7aa patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents: 14993
diff changeset
60 " Quit gracefully to dump coverage information.
47328ce4b7aa patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents: 14993
diff changeset
61 call term_sendkeys(buf, ":qall!\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 17700
diff changeset
62 call TermWait(buf)
17304
9048b6fb05ce patch 8.1.1651: suspend test is flaky on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
63 " Wait until Vim actually exited and shell shows a prompt
9048b6fb05ce patch 8.1.1651: suspend test is flaky on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17164
diff changeset
64 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
17164
7927cf327396 patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents: 16336
diff changeset
65 call StopShellInTerminal(buf)
15523
47328ce4b7aa patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents: 14993
diff changeset
66
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 exe buf . 'bwipe!'
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call delete('Xfoo')
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
70
23165
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
71 func Test_suspend_autocmd()
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
72 CheckFeature terminal
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
73 CheckExecutable /bin/sh
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
74
31369
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
75 " Somehow the modifyOtherKeys response may get to the terminal when using
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
76 " Mac OS. Make t_RK and 'keyprotocol' empty to avoid that.
03da3e28883e patch 9.0.1018: suspend test still fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31359
diff changeset
77 set t_RK= keyprotocol=
31359
adb96415b5b7 patch 9.0.1013: suspend test often fails on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 31347
diff changeset
78
31341
3071d91e52f0 patch 9.0.1004: suspend test sometimes fails on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 23165
diff changeset
79 call WaitForResponses()
3071d91e52f0 patch 9.0.1004: suspend test sometimes fails on MacOS
Bram Moolenaar <Bram@vim.org>
parents: 23165
diff changeset
80
23165
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
81 let buf = term_start('/bin/sh', #{term_rows: 6})
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
82 " Wait for shell prompt.
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
83 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
84
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
85 call term_sendkeys(buf, v:progpath
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
86 \ . " --clean -X"
31377
543cb94c6c09 patch 9.0.1022: suspend test fails on Mac OS when suspending Vim
Bram Moolenaar <Bram@vim.org>
parents: 31369
diff changeset
87 \ . " -c 'set nu keyprotocol='"
23165
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
88 \ . " -c 'let g:count = 0'"
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
89 \ . " -c 'au VimSuspend * let g:count += 1'"
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
90 \ . " -c 'au VimResume * let g:count += 1'"
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
91 \ . " -c 'call setline(1, \"foo\")'"
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
92 \ . " Xfoo\<CR>")
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
93 " Cursor in terminal buffer should be on first line in spawned vim.
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
94 call WaitForAssert({-> assert_equal(' 1 foo', term_getline(buf, '.'))})
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
95
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
96 for suspend_cmd in [":suspend\<CR>",
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
97 \ ":stop\<CR>",
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
98 \ ":suspend!\<CR>",
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
99 \ ":stop!\<CR>",
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
100 \ "\<C-Z>"]
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
101 " Suspend and wait for shell prompt. Then "fg" will restore Vim.
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
102 call term_sendkeys(buf, suspend_cmd)
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
103 call CheckSuspended(buf, 0)
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
104 endfor
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
105
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
106 call term_sendkeys(buf, ":echo g:count\<CR>")
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
107 call TermWait(buf)
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
108 call WaitForAssert({-> assert_match('^10', term_getline(buf, 6))})
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
109
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
110 " Quit gracefully to dump coverage information.
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
111 call term_sendkeys(buf, ":qall!\<CR>")
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
112 call TermWait(buf)
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
113 " Wait until Vim actually exited and shell shows a prompt
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
114 call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
115 call StopShellInTerminal(buf)
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
116
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
117 exe buf . 'bwipe!'
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
118 call delete('Xfoo')
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
119 endfunc
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
120
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
121 " vim: shiftwidth=2 sts=2 expandtab