patch 8.0.0474: the client-server feature is not tested
Problem: The client-server feature is not tested.
Solution: Add a test.
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 2642958..f785679 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -144,6 +144,7 @@
test_channel.res \
test_charsearch.res \
test_cindent.res \
+ test_clientserver.res \
test_cmdline.res \
test_command_count.res \
test_crypt.res \
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index 53f5a2e..e28d162 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -164,6 +164,22 @@
call feedkeys('x', 'nt')
endfunc
+" Get the command to run Vim, with -u NONE and --not-a-term arguments.
+" Returns an empty string on error.
+func GetVimCommand()
+ if !filereadable('vimcmd')
+ return ''
+ endif
+ let cmd = readfile('vimcmd')[0]
+ let cmd = substitute(cmd, '-u \f\+', '-u NONE', '')
+ if cmd !~ '-u NONE'
+ let cmd = cmd . ' -u NONE'
+ endif
+ let cmd .= ' --not-a-term'
+ let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
+ return cmd
+endfunc
+
" Run Vim, using the "vimcmd" file and "-u NORC".
" "before" is a list of Vim commands to be executed before loading plugins.
" "after" is a list of Vim commands to be executed after loading plugins.
@@ -174,7 +190,8 @@
endfunc
func RunVimPiped(before, after, arguments, pipecmd)
- if !filereadable('vimcmd')
+ let cmd = GetVimCommand()
+ if cmd == ''
return 0
endif
let args = ''
@@ -187,18 +204,6 @@
let args .= ' -S Xafter.vim'
endif
- let cmd = readfile('vimcmd')[0]
- let cmd = substitute(cmd, '-u \f\+', '-u NONE', '')
- if cmd !~ '-u NONE'
- let cmd = cmd . ' -u NONE'
- endif
- let cmd .= ' --not-a-term'
-
- " With pipecmd we can't set VIMRUNTIME.
- if a:pipecmd != ''
- let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
- endif
-
exe "silent !" . a:pipecmd . cmd . args . ' ' . a:arguments
if len(a:before) > 0
diff --git a/src/testdir/test_clientserver.vim b/src/testdir/test_clientserver.vim
new file mode 100644
index 0000000..55cc98e
--- /dev/null
+++ b/src/testdir/test_clientserver.vim
@@ -0,0 +1,42 @@
+" Tests for the +clientserver feature.
+
+if !has('job') || !has('clientserver')
+ finish
+endif
+
+source shared.vim
+
+func Test_client_server()
+ let cmd = GetVimCommand()
+ if cmd == ''
+ return
+ endif
+ let name = 'XVIMTEXT'
+ let cmd .= ' --servername ' . name
+ let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
+ call WaitFor('job_status(g:job) == "run"')
+ if job_status(g:job) != 'run'
+ call assert_true(0, 'Cannot run the Vim server')
+ return
+ endif
+
+ " Takes a short while for the server to be active.
+ call WaitFor('serverlist() =~ "' . name . '"')
+ call assert_match(name, serverlist())
+
+ call remote_foreground(name)
+
+ call remote_send(name, ":let testvar = 'yes'\<CR>")
+ call WaitFor('remote_expr("' . name . '", "testvar") == "yes"')
+ call assert_equal('yes', remote_expr(name, "testvar"))
+
+ call remote_send(name, ":qa!\<CR>")
+ call WaitFor('job_status(g:job) == "dead"')
+ if job_status(g:job) != 'dead'
+ call assert_true(0, 'Server did not exit')
+ call job_stop(g:job, 'kill')
+ endif
+endfunc
+
+" Uncomment this line to get a debugging log
+" call ch_logfile('channellog', 'w')