Mercurial > vim
annotate src/testdir/screendump.vim @ 13535:e9ffb5b35266 v8.0.1641
patch 8.0.1641: job in terminal can't communicate with Vim
commit https://github.com/vim/vim/commit/8fbaeb195d9298c3a2a80300b5f96f1adddd2f59
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 25 18:20:17 2018 +0200
patch 8.0.1641: job in terminal can't communicate with Vim
Problem: Job in terminal can't communicate with Vim.
Solution: Add the terminal API.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 25 Mar 2018 18:30:07 +0200 |
parents | f5655d70484f |
children | 3fa880445c99 |
rev | line source |
---|---|
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Functions shared by tests making screen dumps. |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Only load this script once. |
13329
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
4 if exists('*CanRunVimInTerminal') |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 finish |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 endif |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
13329
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
8 " Need to be able to run terminal Vim with 256 colors. On MS-Windows the |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
9 " console only has 16 colors and the GUI can't run in a terminal. |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
10 if !has('terminal') || has('win32') |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
11 func CanRunVimInTerminal() |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
12 return 0 |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
13 endfunc |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
14 finish |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
15 endif |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
16 |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
17 func CanRunVimInTerminal() |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
18 return 1 |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
19 endfunc |
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
20 |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 source shared.vim |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " Run Vim with "arguments" in a new terminal window. |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " By default uses a size of 20 lines and 75 columns. |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " Returns the buffer number of the terminal. |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " Options is a dictionary (not used yet). |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 func RunVimInTerminal(arguments, options) |
13515
eb960e9c75c8
patch 8.0.1631: testing with Vim running in terminal is a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
29 " If Vim doesn't exit a swap file remains, causing other tests to fail. |
eb960e9c75c8
patch 8.0.1631: testing with Vim running in terminal is a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
30 " Remove it here. |
eb960e9c75c8
patch 8.0.1631: testing with Vim running in terminal is a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
31 call delete(".swp") |
eb960e9c75c8
patch 8.0.1631: testing with Vim running in terminal is a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
32 |
13529
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
33 if exists('$COLORFGBG') |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
34 " Clear $COLORFGBG to avoid 'background' being set to "dark", which will |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
35 " only be corrected if the response to t_RB is received, which may be too |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
36 " late. |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
37 let $COLORFGBG = '' |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
38 endif |
f5655d70484f
patch 8.0.1638: popup test fails depending on environment variable
Christian Brabandt <cb@256bit.org>
parents:
13515
diff
changeset
|
39 |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 " Make a horizontal and vertical split, so that we can get exactly the right |
13535
e9ffb5b35266
patch 8.0.1641: job in terminal can't communicate with Vim
Christian Brabandt <cb@256bit.org>
parents:
13529
diff
changeset
|
41 " size terminal window. Works only when the current window is full width. |
e9ffb5b35266
patch 8.0.1641: job in terminal can't communicate with Vim
Christian Brabandt <cb@256bit.org>
parents:
13529
diff
changeset
|
42 call assert_equal(&columns, winwidth(0)) |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 split |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 vsplit |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
13322
0dc2e4998a15
patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents:
13320
diff
changeset
|
46 " Always do this with 256 colors and a light background. |
0dc2e4998a15
patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents:
13320
diff
changeset
|
47 set t_Co=256 background=light |
0dc2e4998a15
patch 8.0.1535: C syntax test still fails when using gvim
Christian Brabandt <cb@256bit.org>
parents:
13320
diff
changeset
|
48 hi Normal ctermfg=NONE ctermbg=NONE |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 let cmd = GetVimCommandClean() |
13320
a90063ec1cd6
patch 8.0.1534: C syntax test fails when using gvim
Christian Brabandt <cb@256bit.org>
parents:
13304
diff
changeset
|
51 " Add -v to have gvim run in the terminal (if possible) |
a90063ec1cd6
patch 8.0.1534: C syntax test fails when using gvim
Christian Brabandt <cb@256bit.org>
parents:
13304
diff
changeset
|
52 let cmd .= ' -v ' . a:arguments |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 let buf = term_start(cmd, {'curwin': 1, 'term_rows': 20, 'term_cols': 75}) |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 call assert_equal([20, 75], term_getsize(buf)) |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 return buf |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 endfunc |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 " Stop a Vim running in terminal buffer "buf". |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 func StopVimInTerminal(buf) |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 call assert_equal("running", term_getstatus(a:buf)) |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13329
diff
changeset
|
62 call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>") |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 call WaitFor('term_getstatus(' . a:buf . ') == "finished"') |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 only! |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 endfunc |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 " Verify that Vim running in terminal buffer "buf" matches the screen dump. |
13329
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
68 " "options" is passed to term_dumpwrite(). |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 " The file name used is "dumps/{filename}.dump". |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 " Will wait for up to a second for the screen dump to match. |
13329
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
71 func VerifyScreenDump(buf, filename, options) |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 let reference = 'dumps/' . a:filename . '.dump' |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 let testfile = a:filename . '.dump.failed' |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 let i = 0 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 while 1 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 call delete(testfile) |
13329
424321d6eea7
patch 8.0.1539: no test for the popup menu positioning
Christian Brabandt <cb@256bit.org>
parents:
13322
diff
changeset
|
78 call term_dumpwrite(a:buf, testfile, a:options) |
13304
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 if readfile(reference) == readfile(testfile) |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 call delete(testfile) |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 break |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 endif |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 if i == 100 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 " Leave the test file around for inspection. |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 call assert_report('See dump file difference: call term_dumpdiff("' . testfile . '", "' . reference . '")') |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 break |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 endif |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 sleep 10m |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 let i += 1 |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 endwhile |
013c44d9dc09
patch 8.0.1526: no test using a screen dump yet
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 endfunc |