annotate src/testdir/test_clientserver.vim @ 11250:ca5550f66b27 v8.0.0511

patch 8.0.0511: message for skipping client-server tests is unclear commit https://github.com/vim/vim/commit/a683ec44c34f0717dcc6a0c03493ba39b879ac38 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 25 20:14:34 2017 +0100 patch 8.0.0511: message for skipping client-server tests is unclear Problem: Menuage for skipping client-server tests is unclear. Solution: Be more specific about what's missing (Hirohito Higashi, Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Sat, 25 Mar 2017 20:15:04 +0100
parents 9612b93820a4
children f0d050a452c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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')
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
48 " 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
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.
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11185
diff changeset
59 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
60
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
61 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
62 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
63 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
64 endif
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 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
67
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
68 " 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
69 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
70 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
71 " 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
72 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
73 endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
74 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
75 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
76
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
77 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
78 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
79
11185
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
80 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
81 let peek_result = 'nothing'
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
82 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
83 " 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
84 if 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('another', peek_result)
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
86 elseif 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('nothing', peek_result)
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
88 else
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
89 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
90 endif
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
91 let g:peek_result = 'empty'
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
92 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
93 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
94 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
95
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 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
97 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
98 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
99 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
100 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
101 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 " 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
105 " call ch_logfile('channellog', 'w')