|
1 | 1 | " Tests for the XDG feature |
2 | 2 |
|
3 | 3 | source check.vim |
4 | | -CheckFeature terminal |
5 | 4 |
|
6 | 5 | source shared.vim |
7 | | -source screendump.vim |
8 | 6 | source mouse.vim |
9 | | -source term_util.vim |
10 | 7 |
|
11 | 8 | func s:get_rcs() |
12 | 9 | let rcs = { |
@@ -77,63 +74,70 @@ func Test_xdg_runtime_files() |
77 | 74 | call writefile(file3, rc3) |
78 | 75 | call writefile(file4, rc4) |
79 | 76 |
|
80 | | - let rows = 20 |
81 | | - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) |
82 | | - call TermWait(buf) |
83 | | - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>") |
84 | | - call WaitForAssert({-> assert_match('XfakeHOME/\.vimrc', term_getline(buf, rows))}) |
85 | | - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>") |
86 | | - call TermWait(buf) |
87 | | - call term_sendkeys(buf, ":redraw!\<cr>") |
88 | | - call TermWait(buf) |
89 | | - call term_sendkeys(buf, ":let g:\<cr>") |
90 | | - call VerifyScreenDump(buf, 'Test_xdg_1', {}) |
91 | | - call StopVimInTerminal(buf) |
| 77 | + " Get the Vim command to run without the '-u NONE' argument |
| 78 | + let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '') |
| 79 | + |
| 80 | + " Test for ~/.vimrc |
| 81 | + let lines =<< trim END |
| 82 | + call assert_match('XfakeHOME/\.vimrc', $MYVIMRC) |
| 83 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 84 | + call assert_equal(#{rc_one: 'one', rc: '.vimrc'}, g:) |
| 85 | + call writefile(v:errors, 'Xresult') |
| 86 | + quit |
| 87 | + END |
| 88 | + call writefile(lines, 'Xscript', 'D') |
| 89 | + call system($'{vimcmd} -S Xscript') |
| 90 | + call assert_equal([], readfile('Xresult')) |
| 91 | + |
92 | 92 | call delete(rc1) |
93 | | - bw |
94 | | - |
95 | | - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) |
96 | | - call TermWait(buf) |
97 | | - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>") |
98 | | - call WaitForAssert({-> assert_match('XfakeHOME/\.vim/vimrc', term_getline(buf, rows))}) |
99 | | - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>") |
100 | | - call TermWait(buf) |
101 | | - call term_sendkeys(buf, ":redraw!\<cr>") |
102 | | - call TermWait(buf) |
103 | | - call term_sendkeys(buf, ":let g:\<cr>") |
104 | | - call VerifyScreenDump(buf, 'Test_xdg_2', {}) |
105 | | - call StopVimInTerminal(buf) |
| 93 | + |
| 94 | + " Test for ~/.vim/vimrc |
| 95 | + let lines =<< trim END |
| 96 | + call assert_match('XfakeHOME/\.vim/vimrc', $MYVIMRC) |
| 97 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 98 | + call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc'}, g:) |
| 99 | + call writefile(v:errors, 'Xresult') |
| 100 | + quit |
| 101 | + END |
| 102 | + call writefile(lines, 'Xscript', 'D') |
| 103 | + call system($'{vimcmd} -S Xscript') |
| 104 | + call assert_equal([], readfile('Xresult')) |
| 105 | + |
106 | 106 | call delete(rc2) |
107 | | - bw |
108 | | - |
109 | | - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) |
110 | | - call TermWait(buf) |
111 | | - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>") |
112 | | - call WaitForAssert({-> assert_match('XfakeHOME/\.config/vim/vimrc', term_getline(buf, rows))}) |
113 | | - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>") |
114 | | - call TermWait(buf) |
115 | | - call term_sendkeys(buf, ":redraw!\<cr>") |
116 | | - call TermWait(buf) |
117 | | - call term_sendkeys(buf, ":let g:\<cr>") |
118 | | - call VerifyScreenDump(buf, 'Test_xdg_3', {}) |
119 | | - call StopVimInTerminal(buf) |
| 107 | + |
| 108 | + " XDG_CONFIG_HOME is set in Github CI runners |
| 109 | + unlet $XDG_CONFIG_HOME |
| 110 | + |
| 111 | + " Test for ~/.config/vim/vimrc |
| 112 | + let lines =<< trim END |
| 113 | + let msg = $'HOME="{$HOME}", ~="{expand("~")}"' |
| 114 | + call assert_match('XfakeHOME/\.config/vim/vimrc', $MYVIMRC, msg) |
| 115 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 116 | + call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc'}, g:) |
| 117 | + call writefile(v:errors, 'Xresult') |
| 118 | + quit |
| 119 | + END |
| 120 | + call writefile(lines, 'Xscript', 'D') |
| 121 | + call system($'{vimcmd} -S Xscript') |
| 122 | + call assert_equal([], readfile('Xresult')) |
| 123 | + |
120 | 124 | call delete(rc3) |
121 | | - bw |
122 | 125 |
|
| 126 | + " Test for ~/xdg/vim/vimrc |
123 | 127 | let $XDG_CONFIG_HOME=expand('~/xdg/') |
124 | | - let buf = RunVimInTerminal('', #{rows: rows, no_clean: 1}) |
125 | | - call TermWait(buf) |
126 | | - call term_sendkeys(buf, ":redraw!\<cr>") |
127 | | - call TermWait(buf) |
128 | | - call term_sendkeys(buf, ":echo \$MYVIMRC[-30:]\<cr>") |
129 | | - call WaitForAssert({-> assert_match('XfakeHOME/xdg/vim/vimrc', term_getline(buf, rows))}) |
130 | | - call term_sendkeys(buf, ":call filter(g:, {idx, _ -> idx =~ '^rc'})\<cr>") |
131 | | - call TermWait(buf) |
132 | | - call term_sendkeys(buf, ":let g:\<cr>") |
133 | | - call VerifyScreenDump(buf, 'Test_xdg_4', {}) |
134 | | - call StopVimInTerminal(buf) |
| 128 | + let lines =<< trim END |
| 129 | + let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"' |
| 130 | + call assert_match('XfakeHOME/xdg/vim/vimrc', $MYVIMRC, msg) |
| 131 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 132 | + call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc'}, g:) |
| 133 | + call writefile(v:errors, 'Xresult') |
| 134 | + quit |
| 135 | + END |
| 136 | + call writefile(lines, 'Xscript', 'D') |
| 137 | + call system($'{vimcmd} -S Xscript') |
| 138 | + call assert_equal([], readfile('Xresult')) |
| 139 | + |
135 | 140 | call delete(rc4) |
136 | | - bw |
137 | 141 | unlet $XDG_CONFIG_HOME |
138 | 142 | endfunc |
139 | 143 |
|
|
0 commit comments