@@ -6,11 +6,7 @@ CheckFeature clientserver
66
77source shared.vim
88
9- func Test_client_server ()
10- let cmd = GetVimCommand ()
11- if cmd == ' '
12- return
13- endif
9+ func Check_X11_Connection ()
1410 if has (' x11' )
1511 if empty ($DISPLAY )
1612 throw ' Skipped: $DISPLAY is not set'
@@ -19,11 +15,19 @@ func Test_client_server()
1915 call remote_send (' xxx' , ' ' )
2016 catch
2117 if v: exception = ~ ' E240:'
22- throw ' Skipped: no connection to the X server'
18+ throw ' Skipped: no connection to the X server'
2319 endif
2420 " ignore other errors
2521 endtry
2622 endif
23+ endfunc
24+
25+ func Test_client_server ()
26+ let cmd = GetVimCommand ()
27+ if cmd == ' '
28+ return
29+ endif
30+ call Check_X11_Connection ()
2731
2832 let name = ' XVIMTEST'
2933 let cmd .= ' --servername ' . name
@@ -72,6 +76,10 @@ func Test_client_server()
7276 endif
7377 let g: testvar = ' myself'
7478 call assert_equal (' myself' , remote_expr (v: servername , ' testvar' ))
79+ call remote_send (v: servername , " :let g:testvar2 = 75\<CR> " )
80+ call feedkeys (' ' , ' x' )
81+ call assert_equal (75 , g: testvar2 )
82+ call assert_fails (' let v = remote_expr(v:servername, "/2")' , ' E449:' )
7583
7684 call remote_send (name, " :call server2client(expand('<client>'), 'got it')\<CR> " , ' g:myserverid' )
7785 call assert_equal (' got it' , g: myserverid- >remote_read (2 ))
@@ -92,6 +100,55 @@ func Test_client_server()
92100 call assert_equal (' another' , g: peek_result )
93101 call assert_equal (' another' , remote_read (g: myserverid , 2 ))
94102
103+ if ! has (' gui_running' )
104+ " In GUI vim, the following tests display a dialog box
105+
106+ let cmd = GetVimProg () .. ' --servername ' .. name
107+
108+ " Run a separate instance to send a command to the server
109+ call remote_expr (name, ' execute("only")' )
110+ call system (cmd .. ' --remote-send ":new Xfile<CR>"' )
111+ call assert_equal (' 2' , remote_expr (name, ' winnr("$")' ))
112+ call assert_equal (' Xfile' , remote_expr (name, ' winbufnr(1)->bufname()' ))
113+ call remote_expr (name, ' execute("only")' )
114+
115+ " Invoke a remote-expr. On MS-Windows, the returned value has a carriage
116+ " return.
117+ let l = system (cmd .. ' --remote-expr "2 + 2"' )
118+ call assert_equal ([' 4' ], split (l , " \n " ))
119+
120+ " Edit multiple files using --remote
121+ call system (cmd .. ' --remote Xfile1 Xfile2 Xfile3' )
122+ call assert_equal (" Xfile1\n Xfile2\n Xfile3\n " , remote_expr (name, ' argv()' ))
123+ eval name- >remote_send (" :%bw!\<CR> " )
124+
125+ " Edit files in separate tab pages
126+ call system (cmd .. ' --remote-tab Xfile1 Xfile2 Xfile3' )
127+ call assert_equal (' 3' , remote_expr (name, ' tabpagenr("$")' ))
128+ call assert_equal (' Xfile2' , remote_expr (name, ' bufname(tabpagebuflist(2)[0])' ))
129+ eval name- >remote_send (" :%bw!\<CR> " )
130+
131+ " Edit a file using --remote-wait
132+ eval name- >remote_send (" :source $VIMRUNTIME/plugin/rrhelper.vim\<CR> " )
133+ call system (cmd .. ' --remote-wait +enew Xfile1' )
134+ call assert_equal (" Xfile1" , remote_expr (name, ' bufname("#")' ))
135+ eval name- >remote_send (" :%bw!\<CR> " )
136+
137+ " Edit files using --remote-tab-wait
138+ call system (cmd .. ' --remote-tabwait +tabonly\|enew Xfile1 Xfile2' )
139+ call assert_equal (' 1' , remote_expr (name, ' tabpagenr("$")' ))
140+ eval name- >remote_send (" :%bw!\<CR> " )
141+
142+ " Error cases
143+ if v: lang == " C" || v: lang = ~ ' ^[Ee]n'
144+ let l = split (system (cmd .. ' --remote +pwd' ), " \n " )
145+ call assert_equal (" Argument missing after: \" +pwd\" " , l [1 ])
146+ endif
147+ let l = system (cmd .. ' --remote-expr "abcd"' )
148+ call assert_match (' ^E449: ' , l )
149+ endif
150+
151+ eval name- >remote_send (" :%bw!\<CR> " )
95152 eval name- >remote_send (" :qa!\<CR> " )
96153 try
97154 call WaitForAssert ({- > assert_equal (" dead" , job_status (job))})
@@ -102,8 +159,8 @@ func Test_client_server()
102159 endif
103160 endtry
104161
105- call assert_fails (" let x= remote_peek([])" , ' E730:' )
106- call assert_fails (" let x= remote_read('vim10')" , ' E277:' )
162+ call assert_fails (" let x = remote_peek([])" , ' E730:' )
163+ call assert_fails (" let x = remote_read('vim10')" , ' E277:' )
107164endfunc
108165
109166" Uncomment this line to get a debugging log
0 commit comments