blob: 55cc98ec8d5aebda0489cbce4af8a4a5ade47239 [file] [log] [blame]
Bram Moolenaar15bf76d2017-03-18 16:18:37 +01001" Tests for the +clientserver feature.
2
3if !has('job') || !has('clientserver')
4 finish
5endif
6
7source shared.vim
8
9func Test_client_server()
10 let cmd = GetVimCommand()
11 if cmd == ''
12 return
13 endif
14 let name = 'XVIMTEXT'
15 let cmd .= ' --servername ' . name
16 let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
17 call WaitFor('job_status(g:job) == "run"')
18 if job_status(g:job) != 'run'
19 call assert_true(0, 'Cannot run the Vim server')
20 return
21 endif
22
23 " Takes a short while for the server to be active.
24 call WaitFor('serverlist() =~ "' . name . '"')
25 call assert_match(name, serverlist())
26
27 call remote_foreground(name)
28
29 call remote_send(name, ":let testvar = 'yes'\<CR>")
30 call WaitFor('remote_expr("' . name . '", "testvar") == "yes"')
31 call assert_equal('yes', remote_expr(name, "testvar"))
32
33 call remote_send(name, ":qa!\<CR>")
34 call WaitFor('job_status(g:job) == "dead"')
35 if job_status(g:job) != 'dead'
36 call assert_true(0, 'Server did not exit')
37 call job_stop(g:job, 'kill')
38 endif
39endfunc
40
41" Uncomment this line to get a debugging log
42" call ch_logfile('channellog', 'w')