annotate src/testdir/test_clientserver.vim @ 11193:75ccc8a15a51 v8.0.0483

patch 8.0.0483: illegal memory access when using :all commit https://github.com/vim/vim/commit/f79225ed4f81bc579bb3360ad2eb06adc8058153 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 18 23:11:04 2017 +0100 patch 8.0.0483: illegal memory access when using :all Problem: Illegal memory access when using :all. (Dominique Pelle) Solution: Adjust the cursor position right after setting "curwin".
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Mar 2017 23:15:04 +0100
parents eb050472e4b4
children 71311d899b42
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
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
9 let s:where = 0
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
10 func Abort(id)
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
11 call assert_report('Test timed out at ' . s:where)
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
12 call FinishTesting()
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
13 endfunc
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
14
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 func Test_client_server()
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 let cmd = GetVimCommand()
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if cmd == ''
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 return
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 endif
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
20
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
21 " Some of these commands may hang when failing.
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
22 call timer_start(10000, 'Abort')
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
23
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
24 let s:where = 1
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
25 let name = 'XVIMTEST'
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let cmd .= ' --servername ' . name
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 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
28 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
29 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
30 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
31 return
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 endif
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
33 let s:where = 2
11175
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())
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
38 let s:where = 3
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call remote_foreground(name)
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
41 let s:where = 4
11175
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>")
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
44 let s:where = 5
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call WaitFor('remote_expr("' . name . '", "testvar") == "yes"')
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
46 let s:where = 6
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal('yes', remote_expr(name, "testvar"))
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
48 let s:where = 7
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
50 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
51 " 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
52 " 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
53 " 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
54 " to send to the terminal window.
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
55 call remote_send(name, ":gui -f\<CR>")
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
56 let s:where = 8
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
57 sleep 500m
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
58 call remote_send(name, ":let testvar = 'maybe'\<CR>")
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
59 let s:where = 9
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
60 call WaitFor('remote_expr("' . name . '", "testvar") == "maybe"')
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
61 let s:where = 10
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
62 call assert_equal('maybe', remote_expr(name, "testvar"))
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
63 let s:where = 11
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')
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
67 let s:where = 12
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
68
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
69 " 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
70 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
71 call remote_startserver('MYSELF')
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
72 let s:where = 13
11177
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', v:servername)
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
74 endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
75 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
76 call assert_equal('myself', remote_expr(v:servername, 'testvar'))
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
77 let s:where = 14
11177
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')
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
80 let s:where = 15
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
81 call assert_equal('got it', remote_read(g:myserverid))
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
82 let s:where = 16
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
83
11185
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
84 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
85 let s:where = 151
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
86 let peek_result = 'nothing'
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
87 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
88 let s:where = 161
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
89 " 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
90 if r > 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', peek_result)
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
92 elseif r == 0
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
93 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
94 else
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
95 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
96 endif
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
97 let g:peek_result = 'empty'
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
98 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
99 let s:where = 171
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
100 call assert_equal('another', g:peek_result)
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
101 let s:where = 181
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
102 call assert_equal('another', remote_read(g:myserverid))
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
103 let s:where = 191
eb050472e4b4 patch 8.0.0479: remote_peek() is not tested
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
104
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 call remote_send(name, ":qa!\<CR>")
11181
13544aa85dc0 patch 8.0.0477: the client-server test may hang when failing
Christian Brabandt <cb@256bit.org>
parents: 11177
diff changeset
106 let s:where = 17
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 call WaitFor('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
108 let s:where = 18
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 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
110 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
111 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
112 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 " 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
116 " call ch_logfile('channellog', 'w')