annotate src/testdir/test_suspend.vim @ 20169:bd970e6fa5d4

Added tag v8.2.0639 for changeset be661435893a4211d8360b4475cf80cf6ddbc53f
author Bram Moolenaar <Bram@vim.org>
date Sat, 25 Apr 2020 17:15:04 +0200
parents c087099e9163
children 08940efa6b4e
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
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 source shared.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()
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 if !has('terminal') || !executable('/bin/sh')
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 return
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 endif
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 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
26 " 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
27 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
28
17700
97b859062d67 patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
29 call term_sendkeys(buf, v:progpath
97b859062d67 patch 8.1.1847: suspend test is failing
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
30 \ . " --clean -X"
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 \ . " -c 'set nu'"
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 \ . " -c 'call setline(1, \"foo\")'"
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 \ . " Xfoo\<CR>")
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " 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
35 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
36
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 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
38 \ ":stop\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 \ ":suspend!\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 \ ":stop!\<CR>",
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 \ "\<C-Z>"]
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 " 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
43 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
44 call CheckSuspended(buf, 0)
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endfor
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " 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
48 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
49 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
50 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
51 " Wait for shell prompt.
16336
b1e69c9e4c67 patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents: 15523
diff changeset
52 call CheckSuspended(buf, 1)
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
15523
47328ce4b7aa patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents: 14993
diff changeset
54 " 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
55 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
56 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
57 " 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
58 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
59 call StopShellInTerminal(buf)
15523
47328ce4b7aa patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents: 14993
diff changeset
60
14832
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 exe buf . 'bwipe!'
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call delete('Xfoo')
d6752747348a patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 endfunc