annotate src/testdir/test_clientserver.vim @ 11177:76fb679a310e v8.0.0475

patch 8.0.0475: not enough testing for the client-server feature commit https://github.com/vim/vim/commit/7416f3e73ab2c4e7ae3adc2ff6e70234f7d40d2e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 18 18:10:13 2017 +0100 patch 8.0.0475: not enough testing for the client-server feature Problem: Not enough testing for the client-server feature. Solution: Add more tests. Add the remote_startserver() function. Fix that a locally evaluated expression uses function-local variables.
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Mar 2017 18:15:04 +0100
parents 9836b701afd9
children 13544aa85dc0
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
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let name = 'XVIMTEXT'
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let cmd .= ' --servername ' . name
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 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
17 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
18 if 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
19 call assert_true(0, 'Cannot run the Vim server')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 return
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 " 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
24 call WaitFor('serverlist() =~ "' . name . '"')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 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
26
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call remote_foreground(name)
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call remote_send(name, ":let testvar = 'yes'\<CR>")
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call WaitFor('remote_expr("' . name . '", "testvar") == "yes"')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal('yes', remote_expr(name, "testvar"))
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
33 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
34 " 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
35 " 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
36 " 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
37 " 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
38 call remote_send(name, ":gui -f\<CR>")
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
39 sleep 500m
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
40 call remote_send(name, ":let testvar = 'maybe'\<CR>")
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
41 call WaitFor('remote_expr("' . name . '", "testvar") == "maybe"')
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
42 call assert_equal('maybe', remote_expr(name, "testvar"))
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
43 endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
44
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
45 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
46
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
47 " 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
48 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
49 call remote_startserver('MYSELF')
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
50 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
51 endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
52 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
53 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
54
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, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
56 call assert_equal('got it', remote_read(g:myserverid))
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11175
diff changeset
57
11175
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 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
59 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
60 if 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
61 call assert_true(0, 'Server did not exit')
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63 endif
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endfunc
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65
9836b701afd9 patch 8.0.0474: the client-server feature is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 " 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
67 " call ch_logfile('channellog', 'w')