Mercurial > vim
annotate src/testdir/test_clientserver.vim @ 11242:9612b93820a4 v8.0.0507
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
commit https://github.com/vim/vim/commit/a2845b8f5a3058c8c89699771ffd4d69513b097d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 25 15:20:06 2017 +0100
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Problem: Client-server tests fail when $DISPLAY is not set.
Solution: Check for E240 before running the test.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 25 Mar 2017 15:30:04 +0100 |
parents | 71311d899b42 |
children | ca5550f66b27 |
rev | line source |
---|---|
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for the +clientserver feature. |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 if !has('job') || !has('clientserver') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 finish |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 endif |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 source shared.vim |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 func Test_client_server() |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let cmd = GetVimCommand() |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 if cmd == '' |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 return |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 endif |
11242
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
14 if has('unix') |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
15 try |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
16 call remote_send('xxx', '') |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
17 catch |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
18 if v:exception =~ 'E240:' |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
19 " No connection to the X server, give up. |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
20 return |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
21 endif |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
22 " ignore other errors |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
23 endtry |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
24 endif |
11181
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
25 |
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
26 let name = 'XVIMTEST' |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 let cmd .= ' --servername ' . name |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call WaitFor('job_status(g:job) == "run"') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 if job_status(g:job) != 'run' |
11181
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
31 call assert_report('Cannot run the Vim server') |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 return |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 endif |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 " Takes a short while for the server to be active. |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call WaitFor('serverlist() =~ "' . name . '"') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_match(name, serverlist()) |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call remote_foreground(name) |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call remote_send(name, ":let testvar = 'yes'\<CR>") |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
42 call WaitFor('remote_expr("' . name . '", "testvar", "", 1) == "yes"') |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
43 call assert_equal('yes', remote_expr(name, "testvar", "", 2)) |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
45 if has('unix') && has('gui') && !has('gui_running') |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
46 " Running in a terminal and the GUI is avaiable: Tell the server to open |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
47 " the GUI and check that the remote command still works. |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
48 " Need to wait for the GUI to start up, otherwise the send hangs in trying |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
49 " to send to the terminal window. |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
50 if has('gui_athena') || has('gui_motif') |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
51 " For those GUIs, ignore the 'failed to create input context' error. |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
52 call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>") |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
53 else |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
54 call remote_send(name, ":gui -f\<CR>") |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
55 endif |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
56 " Wait for the server to be up and answering requests. |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
57 call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""') |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
58 |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
59 call remote_send(name, ":let testvar = 'maybe'\<CR>") |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
60 call WaitFor('remote_expr("' . name . '", "testvar", "", 1) == "maybe"') |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
61 call assert_equal('maybe', remote_expr(name, "testvar", "", 2)) |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
62 endif |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
63 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
64 call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241') |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
65 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
66 " Expression evaluated locally. |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
67 if v:servername == '' |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
68 call remote_startserver('MYSELF') |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
69 " May get MYSELF1 when running the test again. |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
70 call assert_match('MYSELF', v:servername) |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
71 endif |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
72 let g:testvar = 'myself' |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
73 call assert_equal('myself', remote_expr(v:servername, 'testvar')) |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
74 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
75 call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid') |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
76 call assert_equal('got it', remote_read(g:myserverid, 2)) |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
77 |
11185
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
78 call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid') |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
79 let peek_result = 'nothing' |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
80 let r = remote_peek(g:myserverid, 'peek_result') |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
81 " unpredictable whether the result is already avaialble. |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
82 if r > 0 |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
83 call assert_equal('another', peek_result) |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
84 elseif r == 0 |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
85 call assert_equal('nothing', peek_result) |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
86 else |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
87 call assert_report('remote_peek() failed') |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
88 endif |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
89 let g:peek_result = 'empty' |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
90 call WaitFor('remote_peek(g:myserverid, "g:peek_result") > 0') |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
91 call assert_equal('another', g:peek_result) |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
92 call assert_equal('another', remote_read(g:myserverid, 2)) |
11185
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
93 |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 call remote_send(name, ":qa!\<CR>") |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 call WaitFor('job_status(g:job) == "dead"') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 if job_status(g:job) != 'dead' |
11181
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
97 call assert_report('Server did not exit') |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 call job_stop(g:job, 'kill') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 endif |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 endfunc |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 " Uncomment this line to get a debugging log |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 " call ch_logfile('channellog', 'w') |