Mercurial > vim
annotate src/testdir/test_suspend.vim @ 16548:37e39c5ddf12
Added tag v8.1.1277 for changeset 9ebcc19aa4187895885c007d8452623c6d377e5b
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 May 2019 16:15:05 +0200 |
parents | b1e69c9e4c67 |
children | 7927cf327396 |
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 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
16336
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
5 func CheckSuspended(buf, fileExists) |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
6 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
|
7 |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
8 if a:fileExists |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
9 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
|
10 else |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
11 " 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
|
12 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
|
13 endif |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
14 |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
15 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
|
16 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
|
17 endfunc |
b1e69c9e4c67
patch 8.1.1173: suspend test has duplicated lines
Bram Moolenaar <Bram@vim.org>
parents:
15523
diff
changeset
|
18 |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 func Test_suspend() |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 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
|
21 return |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 endif |
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 |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call term_sendkeys(buf, v:progpath |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 \ . " --clean -X" |
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>") |
47328ce4b7aa
patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents:
14993
diff
changeset
|
55 call term_wait(buf) |
47328ce4b7aa
patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents:
14993
diff
changeset
|
56 call Stop_shell_in_terminal(buf) |
47328ce4b7aa
patch 8.1.0769: :stop is covered in two tests
Bram Moolenaar <Bram@vim.org>
parents:
14993
diff
changeset
|
57 |
14832
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 exe buf . 'bwipe!' |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 call delete('Xfoo') |
d6752747348a
patch 8.1.0428: the :suspend command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 endfunc |