blob: ae931fd29123e4c22c9822a261b1c8c0a2de6bfc [file] [log] [blame]
Christian Brabandtcc979b42024-01-23 21:13:58 +01001" Test for the --remote functionality
2
3source check.vim
4CheckFeature clientserver
5CheckFeature terminal
6
7source shared.vim
8source screendump.vim
9source mouse.vim
10source term_util.vim
11
12let s:remote_works = 0
13let s:skip = 'Skipped: --remote feature is not possible'
14
15" nees to be run as first test to verify, that vim --servername works
16func Verify_remote_feature_works()
17 CheckRunVimInTerminal
18 enew
19 let buf = RunVimInTerminal('--servername XVIMTEST', {'rows': 8})
20 call TermWait(buf)
21 let cmd = GetVimCommandCleanTerm() .. '--serverlist'
22 call term_sendkeys(buf, ":r! " .. cmd .. "\<CR>")
23 call TermWait(buf)
24 call term_sendkeys(buf, ":w! XVimRemoteTest.txt\<CR>")
25 call TermWait(buf)
26 call term_sendkeys(buf, ":q\<CR>")
27 call StopVimInTerminal(buf)
28 bw!
29 let result = readfile('XVimRemoteTest.txt')
30 call delete('XVimRemoteTest.txt')
31 if empty(result)
32 throw s:skip
33 endif
34 let s:remote = 1
35endfunc
36
37call Verify_remote_feature_works()
38
39if !s:remote
40 finish
41endif
42
43func Test_remote_servername()
44 CheckRunVimInTerminal
45
46 " That is the file we want the server to open,
47 " despite the wildignore setting
48 call writefile(range(1, 20), 'XTEST.txt', 'D')
49 " just a dummy file, so that the ':wq' further down is successful
50 call writefile(range(1, 20), 'Xdummy.log', 'D')
51
52 " Run Vim in a terminal and open a terminal window to run Vim in.
53 let lines =<< trim END
54 set wildignore=*.txt
55 END
56 call writefile(lines, 'XRemoteEditing.vim', 'D')
57 let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing.vim Xdummy.log', {'rows': 8})
58 call TermWait(buf)
59 botright new
60 " wildignore setting should be ignored and the XVIMTEST server should now
61 " open XTEST.txt, if wildignore setting is not ignored, the server
62 " will continue with the Xdummy.log file
63 let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent XTEST.txt', {'rows': 5, 'wait_for_ruler': 0})
64 " job should be no-longer running, so we can just close it
65 exe buf2 .. 'bw!'
66 call term_sendkeys(buf, ":sil :3,$d\<CR>")
67 call TermWait(buf)
68 call term_sendkeys(buf, ":wq!\<CR>")
69 call TermWait(buf)
70 if term_getstatus(buf) == 'running'
71 call StopVimInTerminal(buf)
72 endif
73 let buf_contents = readfile('XTEST.txt')
74 call assert_equal(2, len(buf_contents))
75 bw!
76 close
77endfunc
78
79" vim: shiftwidth=2 sts=2 expandtab