summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-18 16:18:37 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-18 16:18:37 +0100
commit15bf76d40be1f1622ff5cc16596c308e76e2ca94 (patch)
treee3e19239a9369f65db8d135b3732ee28ae96cca7
parent8c34aa09a449a5c1c2d1141b6fafa90f29b3fc12 (diff)
downloadvim-15bf76d40be1f1622ff5cc16596c308e76e2ca94.zip
patch 8.0.0474: the client-server feature is not tested
Problem: The client-server feature is not tested. Solution: Add a test.
-rw-r--r--src/Makefile3
-rw-r--r--src/os_mswin.c9
-rw-r--r--src/testdir/Make_all.mak1
-rw-r--r--src/testdir/shared.vim31
-rw-r--r--src/testdir/test_clientserver.vim42
-rw-r--r--src/version.c2
6 files changed, 72 insertions, 16 deletions
diff --git a/src/Makefile b/src/Makefile
index 1af1e17aa..315548bc1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2097,11 +2097,12 @@ test_arglist \
test_breakindent \
test_bufwintabinfo \
test_cdo \
+ test_changedtick \
test_channel \
test_charsearch \
test_charsearch_utf8 \
- test_changedtick \
test_cindent \
+ test_clientserver \
test_cmdline \
test_command_count \
test_crypt \
diff --git a/src/os_mswin.c b/src/os_mswin.c
index a713ea190..166305298 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -2105,11 +2105,15 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
str = serverConvert(client_enc, (char_u *)data->lpData, &tofree);
res = eval_client_expr_to_string(str);
- vim_free(tofree);
if (res == NULL)
{
- res = vim_strsave((char_u *)_(e_invexprmsg));
+ char *err = _(e_invexprmsg);
+ size_t len = STRLEN(str) + STRLEN(err) + 5;
+
+ res = alloc(len);
+ if (res != NULL)
+ vim_snprintf((char *)res, len, "%s: \"%s\"", err, str);
reply.dwData = COPYDATA_ERROR_RESULT;
}
else
@@ -2120,6 +2124,7 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
serverSendEnc(sender);
retval = (int)SendMessage(sender, WM_COPYDATA,
(WPARAM)message_window, (LPARAM)(&reply));
+ vim_free(tofree);
vim_free(res);
return retval;
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 264295884..f785679a4 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -144,6 +144,7 @@ NEW_TESTS = test_arabic.res \
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 53f5a2e86..e28d162b8 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -164,6 +164,22 @@ func s:feedkeys(timer)
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 @@ func RunVim(before, after, arguments)
endfunc
func RunVimPiped(before, after, arguments, pipecmd)
- if !filereadable('vimcmd')
+ let cmd = GetVimCommand()
+ if cmd == ''
return 0
endif
let args = ''
@@ -187,18 +204,6 @@ func RunVimPiped(before, after, arguments, pipecmd)
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 000000000..55cc98ec8
--- /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')
diff --git a/src/version.c b/src/version.c
index 8237679a1..72c8e78dd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 474,
+/**/
473,
/**/
472,