Mercurial > vim
annotate src/testdir/test_clientserver.vim @ 12001:fecb0ff6e8cf v8.0.0881
patch 8.0.0881: win32.mak no longer included in Windows SDK
commit https://github.com/vim/vim/commit/e16b00a1582dbff7b76b0631d935531059cf7b47
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 6 17:38:06 2017 +0200
patch 8.0.0881: win32.mak no longer included in Windows SDK
Problem: win32.mak no longer included in Windows SDK.
Solution: Do not include win32.mak. (Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Aug 2017 17:45:03 +0200 |
parents | f0d050a452c5 |
children | 6ef5e636f246 |
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 |
11250
ca5550f66b27
patch 8.0.0511: message for skipping client-server tests is unclear
Christian Brabandt <cb@256bit.org>
parents:
11242
diff
changeset
|
14 if has('x11') |
ca5550f66b27
patch 8.0.0511: message for skipping client-server tests is unclear
Christian Brabandt <cb@256bit.org>
parents:
11242
diff
changeset
|
15 if empty($DISPLAY) |
ca5550f66b27
patch 8.0.0511: message for skipping client-server tests is unclear
Christian Brabandt <cb@256bit.org>
parents:
11242
diff
changeset
|
16 throw 'Skipped: $DISPLAY is not set' |
ca5550f66b27
patch 8.0.0511: message for skipping client-server tests is unclear
Christian Brabandt <cb@256bit.org>
parents:
11242
diff
changeset
|
17 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
|
18 try |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
19 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
|
20 catch |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
21 if v:exception =~ 'E240:' |
11250
ca5550f66b27
patch 8.0.0511: message for skipping client-server tests is unclear
Christian Brabandt <cb@256bit.org>
parents:
11242
diff
changeset
|
22 throw 'Skipped: no connection to the X server' |
11242
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
23 endif |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
24 " 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
|
25 endtry |
9612b93820a4
patch 8.0.0507: client-server tests fail when $DISPLAY is not set
Christian Brabandt <cb@256bit.org>
parents:
11211
diff
changeset
|
26 endif |
11181
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
27 |
13544aa85dc0
patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents:
11177
diff
changeset
|
28 let name = 'XVIMTEST' |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 let cmd .= ' --servername ' . name |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 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
|
34 return |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 endif |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " 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
|
38 call WaitFor('serverlist() =~ "' . name . '"') |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 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
|
40 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call remote_foreground(name) |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
47 if has('unix') && has('gui') && !has('gui_running') |
11500
f0d050a452c5
patch 8.0.0633: the client-server test is still a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
11250
diff
changeset
|
48 " Running in a terminal and the GUI is available: Tell the server to open |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
49 " 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
|
50 " 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
|
51 " 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
|
52 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
|
53 " 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
|
54 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
|
55 else |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
56 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
|
57 endif |
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
58 " Wait for the server to be up and answering requests. |
11500
f0d050a452c5
patch 8.0.0633: the client-server test is still a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
11250
diff
changeset
|
59 sleep 100m |
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 . '", "v:version", "", 1) != ""') |
11500
f0d050a452c5
patch 8.0.0633: the client-server test is still a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
11250
diff
changeset
|
61 call assert_true(remote_expr(name, "v:version", "", 1) != "") |
11211
71311d899b42
patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents:
11185
diff
changeset
|
62 |
11177
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 endif |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
67 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
68 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
|
69 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
70 " 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
|
71 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
|
72 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
|
73 " 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
|
74 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
|
75 endif |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
76 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
|
77 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
|
78 |
76fb679a310e
patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents:
11175
diff
changeset
|
79 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
|
80 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
|
81 |
11185
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
82 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
|
83 let peek_result = 'nothing' |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
84 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
|
85 " 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
|
86 if r > 0 |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
87 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
|
88 elseif r == 0 |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
89 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
|
90 else |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
91 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
|
92 endif |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
93 let g:peek_result = 'empty' |
eb050472e4b4
patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents:
11181
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 |
11175
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 endif |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 endfunc |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 |
9836b701afd9
patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 " 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
|
107 " call ch_logfile('channellog', 'w') |