Mercurial > vim
annotate src/testdir/test_suspend.vim @ 27678:1646525507aa v8.2.4365
patch 8.2.4365: sticky command modifiers are too sticky
Commit: https://github.com/vim/vim/commit/cdf04859699bdde891b5b52ea821d0bebd7e8ee0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 12 22:13:06 2022 +0000
patch 8.2.4365: sticky command modifiers are too sticky
Problem: sticky command modifiers are too sticky.
Solution: Do not apply command modifiers to a called function. (closes https://github.com/vim/vim/issues/9751)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Feb 2022 23:15:03 +0100 |
parents | a916fca16d4b |
children | 3071d91e52f0 |
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 |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
16336
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
6 func CheckSuspended(buf, fileExists) |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
7 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
|
8 |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
9 if a:fileExists |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
10 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
|
11 else |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
12 " 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
|
13 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
|
14 endif |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
15 |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
16 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
|
17 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
|
18 endfunc |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
19 |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 func Test_suspend() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
21 CheckFeature terminal |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
22 CheckExecutable /bin/sh |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 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
|
25 " 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
|
26 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
|
27 |
17700
97b859062d67
patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
28 call term_sendkeys(buf, v:progpath |
97b859062d67
patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents:
17698
diff
changeset
|
29 \ . " --clean -X" |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 \ . " -c 'set nu'" |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 \ . " -c 'call setline(1, \"foo\")'" |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ . " Xfoo\<CR>") |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 " 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
|
34 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
|
35 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 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
|
37 \ ":stop\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 \ ":suspend!\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 \ ":stop!\<CR>", |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 \ "\<C-Z>"] |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 " 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
|
42 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
|
43 call CheckSuspended(buf, 0) |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 endfor |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 " 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
|
47 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
|
48 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
|
49 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
|
50 " Wait for shell prompt. |
16336
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
51 call CheckSuspended(buf, 1) |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 |
15523
47328ce4b7aa
patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents:
14993
diff
changeset
|
53 " 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
|
54 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
|
55 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
|
56 " 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
|
57 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
|
58 call StopShellInTerminal(buf) |
15523
47328ce4b7aa
patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents:
14993
diff
changeset
|
59 |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 exe buf . 'bwipe!' |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 call delete('Xfoo') |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
63 |
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
|
64 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
|
65 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
|
66 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
|
67 |
a916fca16d4b
patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
68 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
|
69 " 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
|
70 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
|
71 |
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 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
|
73 \ . " --clean -X" |
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 \ . " -c 'set nu'" |
a916fca16d4b
patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
75 \ . " -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
|
76 \ . " -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
|
77 \ . " -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
|
78 \ . " -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
|
79 \ . " 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
|
80 " 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
|
81 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
|
82 |
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 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
|
84 \ ":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
|
85 \ ":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
|
86 \ ":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
|
87 \ "\<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
|
88 " 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
|
89 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
|
90 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
|
91 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
|
92 |
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 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
|
94 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
|
95 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
|
96 |
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 " 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
|
98 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
|
99 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
|
100 " 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
|
101 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
|
102 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
|
103 |
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 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
|
105 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
|
106 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
|
107 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
108 " vim: shiftwidth=2 sts=2 expandtab |