Christian Brabandt | cc979b4 | 2024-01-23 21:13:58 +0100 | [diff] [blame] | 1 | " Test for the --remote functionality |
| 2 | |
Christian Brabandt | cc979b4 | 2024-01-23 21:13:58 +0100 | [diff] [blame] | 3 | CheckFeature clientserver |
| 4 | CheckFeature terminal |
| 5 | |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 6 | source util/screendump.vim |
| 7 | source util/mouse.vim |
Christian Brabandt | cc979b4 | 2024-01-23 21:13:58 +0100 | [diff] [blame] | 8 | |
| 9 | let s:remote_works = 0 |
| 10 | let s:skip = 'Skipped: --remote feature is not possible' |
| 11 | |
zeertzjq | 75a7355 | 2024-04-28 16:20:55 +0200 | [diff] [blame] | 12 | " needs to be run as first test to verify, that vim --servername works |
Christian Brabandt | cc979b4 | 2024-01-23 21:13:58 +0100 | [diff] [blame] | 13 | func Verify_remote_feature_works() |
| 14 | CheckRunVimInTerminal |
| 15 | enew |
| 16 | let buf = RunVimInTerminal('--servername XVIMTEST', {'rows': 8}) |
| 17 | call TermWait(buf) |
| 18 | let cmd = GetVimCommandCleanTerm() .. '--serverlist' |
| 19 | call term_sendkeys(buf, ":r! " .. cmd .. "\<CR>") |
| 20 | call TermWait(buf) |
| 21 | call term_sendkeys(buf, ":w! XVimRemoteTest.txt\<CR>") |
| 22 | call TermWait(buf) |
| 23 | call term_sendkeys(buf, ":q\<CR>") |
| 24 | call StopVimInTerminal(buf) |
| 25 | bw! |
| 26 | let result = readfile('XVimRemoteTest.txt') |
| 27 | call delete('XVimRemoteTest.txt') |
| 28 | if empty(result) |
| 29 | throw s:skip |
| 30 | endif |
| 31 | let s:remote = 1 |
| 32 | endfunc |
| 33 | |
| 34 | call Verify_remote_feature_works() |
| 35 | |
| 36 | if !s:remote |
| 37 | finish |
| 38 | endif |
| 39 | |
| 40 | func Test_remote_servername() |
| 41 | CheckRunVimInTerminal |
| 42 | |
| 43 | " That is the file we want the server to open, |
| 44 | " despite the wildignore setting |
| 45 | call writefile(range(1, 20), 'XTEST.txt', 'D') |
| 46 | " just a dummy file, so that the ':wq' further down is successful |
| 47 | call writefile(range(1, 20), 'Xdummy.log', 'D') |
| 48 | |
| 49 | " Run Vim in a terminal and open a terminal window to run Vim in. |
| 50 | let lines =<< trim END |
| 51 | set wildignore=*.txt |
| 52 | END |
| 53 | call writefile(lines, 'XRemoteEditing.vim', 'D') |
| 54 | let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing.vim Xdummy.log', {'rows': 8}) |
| 55 | call TermWait(buf) |
| 56 | botright new |
| 57 | " wildignore setting should be ignored and the XVIMTEST server should now |
| 58 | " open XTEST.txt, if wildignore setting is not ignored, the server |
| 59 | " will continue with the Xdummy.log file |
| 60 | let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent XTEST.txt', {'rows': 5, 'wait_for_ruler': 0}) |
| 61 | " job should be no-longer running, so we can just close it |
| 62 | exe buf2 .. 'bw!' |
| 63 | call term_sendkeys(buf, ":sil :3,$d\<CR>") |
| 64 | call TermWait(buf) |
| 65 | call term_sendkeys(buf, ":wq!\<CR>") |
| 66 | call TermWait(buf) |
| 67 | if term_getstatus(buf) == 'running' |
| 68 | call StopVimInTerminal(buf) |
| 69 | endif |
| 70 | let buf_contents = readfile('XTEST.txt') |
| 71 | call assert_equal(2, len(buf_contents)) |
| 72 | bw! |
| 73 | close |
| 74 | endfunc |
| 75 | |
Christian Brabandt | 349f5cd | 2024-04-19 15:22:33 +0200 | [diff] [blame] | 76 | func Test_remote_servername_shellslash() |
| 77 | " Note this test does not currently run on Windows |
| 78 | " because: |
| 79 | " 1) we cannot run the gui version of Vim inside a terminal |
| 80 | " 2) Running Windows vim.exe inside a terminal would work, but is |
| 81 | " disabled because of the limited colors inside the default Windows |
| 82 | " console (see CanRunVimInTerminal in term_util.vim) |
| 83 | CheckRunVimInTerminal |
| 84 | CheckMSWindows |
| 85 | |
| 86 | " That is the file we want the server to open, |
| 87 | " despite the wildignore setting |
| 88 | call mkdir(expand('~/remote/'), 'pD') |
| 89 | call writefile(range(1, 20), expand('~/remote/XTEST.txt'), 'D') |
| 90 | " just a dummy file, so that the ':wq' further down is successful |
| 91 | call writefile(range(1, 20), 'Xdummy.log', 'D') |
| 92 | |
| 93 | " Run Vim in a terminal and open a terminal window to run Vim in. |
| 94 | let lines =<< trim END |
| 95 | set shellslash |
| 96 | cd ~/remote |
| 97 | END |
| 98 | call writefile(lines, 'XRemoteEditing1.vim', 'D') |
| 99 | let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing1.vim Xdummy.log', {'rows': 10}) |
| 100 | call TermWait(buf) |
| 101 | |
| 102 | " wildignore setting should be ignored and the XVIMTEST server should now |
| 103 | " open XTEST.txt, if wildignore setting is not ignored, the server |
| 104 | " will continue with the Xdummy.log file |
| 105 | let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent ~/remote/XTEST.txt', {'rows': 5, 'wait_for_ruler': 0}) |
| 106 | " job should be no-longer running, so we can just close it |
| 107 | exe buf2 .. 'bw!' |
| 108 | |
| 109 | call term_sendkeys(buf, ":pwd\<CR>") |
| 110 | call WaitForAssert({-> assert_match('remote/$', term_getline(buf, 10))}, 1000) |
| 111 | call TermWait(buf) |
| 112 | call term_sendkeys(buf, ":q!\<CR>") |
| 113 | call TermWait(buf) |
| 114 | if term_getstatus(buf) == 'running' |
| 115 | call StopVimInTerminal(buf) |
| 116 | endif |
| 117 | bw! |
| 118 | close |
| 119 | endfunc |
| 120 | |
Christian Brabandt | cc979b4 | 2024-01-23 21:13:58 +0100 | [diff] [blame] | 121 | " vim: shiftwidth=2 sts=2 expandtab |