|
3 | 3 | source check.vim
|
4 | 4 |
|
5 | 5 | source shared.vim
|
6 |
| -source mouse.vim |
7 | 6 |
|
8 | 7 | func s:get_rcs()
|
9 | 8 | let rcs = {
|
@@ -44,7 +43,7 @@ func Test_xdg_runtime_files()
|
44 | 43 | call mkdir(expand('~/.vim/'), 'pD')
|
45 | 44 | call mkdir(expand('~/.config/vim/'), 'pD')
|
46 | 45 | call mkdir(expand('~/xdg/vim/'), 'pD')
|
47 |
| - |
| 46 | + |
48 | 47 | let rc1=expand('~/.vimrc')
|
49 | 48 | let rc2=expand('~/.vim/vimrc')
|
50 | 49 | let rc3=expand('~/.config/vim/vimrc')
|
@@ -147,15 +146,153 @@ func Test_xdg_version()
|
147 | 146 | unlet $XDG_CONFIG_HOME
|
148 | 147 | let a = execute(':version')->split('\n')
|
149 | 148 | let a = filter(a, { _, val -> val =~ '\.config\|XDG_CONFIG_HOME' })
|
150 |
| - call assert_equal(1, len(a)) |
151 |
| - call assert_match('\~/.config/vim/vimrc', a[0]) |
| 149 | + " There should be 1 entry for gvimrc and 1 entry for vimrc, |
| 150 | + " but only if Vim was compiled with gui support |
| 151 | + call assert_equal(1 + has("gui"), len(a)) |
| 152 | + call assert_match('\~/\.config/vim/vimrc', a[0]) |
| 153 | + if has("gui") |
| 154 | + call assert_match('\~/\.config/vim/gvimrc', a[1]) |
| 155 | + endif |
152 | 156 |
|
153 | 157 | let $XDG_CONFIG_HOME = expand('~/.xdg')
|
154 | 158 | let a = execute(':version')->split('\n')
|
155 | 159 | let a = filter(a, { _, val -> val =~ '\.config\|XDG_CONFIG_HOME' })
|
156 |
| - call assert_equal(1, len(a)) |
| 160 | + call assert_equal(1 + has("gui"), len(a)) |
157 | 161 | call assert_match('XDG_CONFIG_HOME/vim/vimrc', a[0])
|
| 162 | + if has("gui") |
| 163 | + call assert_match('XDG_CONFIG_HOME/vim/gvimrc', a[1]) |
| 164 | + endif |
| 165 | + unlet $XDG_CONFIG_HOME |
| 166 | +endfunc |
| 167 | + |
| 168 | +" Test for gvimrc, must be last, since it starts the GUI |
| 169 | +" and sources a few extra test files |
| 170 | +func Test_zzz_xdg_runtime_files() |
| 171 | + CheckCanRunGui |
| 172 | + CheckUnix |
| 173 | + |
| 174 | + " Is setup in Github Runner |
| 175 | + unlet $XDG_CONFIG_HOME |
| 176 | + source setup_gui.vim |
| 177 | + call GUISetUpCommon() |
| 178 | + |
| 179 | + " This tests, that the initialization file from |
| 180 | + " ~/.vimrc, ~/.vim/vimrc and ~/.config/vim/vimrc (or |
| 181 | + " $XDG_HOMECONFIG/vim/vimrc) are sourced in that order |
| 182 | + call mkdir(expand('~/.vim/'), 'pD') |
| 183 | + call mkdir(expand('~/.config/vim/'), 'pD') |
| 184 | + call mkdir(expand('~/xdg/vim/'), 'pD') |
| 185 | + |
| 186 | + let rc1=expand('~/.gvimrc') |
| 187 | + let rc2=expand('~/.vim/gvimrc') |
| 188 | + let rc3=expand('~/.config/vim/gvimrc') |
| 189 | + let rc4=expand('~/xdg/vim/gvimrc') |
| 190 | + |
| 191 | + " g:rc_one|two|three|four is to verify, that the other |
| 192 | + " init files are not sourced |
| 193 | + " g:rc is to verify which rc file has been loaded. |
| 194 | + let file1 =<< trim CODE |
| 195 | + let g:rc_one = 'one' |
| 196 | + let g:rc = '.gvimrc' |
| 197 | + CODE |
| 198 | + let file2 =<< trim CODE |
| 199 | + let g:rc_two = 'two' |
| 200 | + let g:rc = '.vim/gvimrc' |
| 201 | + CODE |
| 202 | + let file3 =<< trim CODE |
| 203 | + let g:rc_three = 'three' |
| 204 | + let g:rc = '.config/vim/gvimrc' |
| 205 | + CODE |
| 206 | + let file4 =<< trim CODE |
| 207 | + let g:rc_four = 'four' |
| 208 | + let g:rc = 'xdg/vim/gvimrc' |
| 209 | + CODE |
| 210 | + call writefile(file1, rc1) |
| 211 | + call writefile(file2, rc2) |
| 212 | + call writefile(file3, rc3) |
| 213 | + call writefile(file4, rc4) |
| 214 | + |
| 215 | + " Get the Vim command to run without the '-u NONE' argument |
| 216 | + let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '') |
| 217 | + |
| 218 | + " Test for ~/.gvimrc |
| 219 | + let lines =<< trim END |
| 220 | + " Ignore the "failed to create input context" error. |
| 221 | + call test_ignore_error('E285') |
| 222 | + gui -f |
| 223 | + call assert_match('Xhome/\.gvimrc', $MYGVIMRC) |
| 224 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 225 | + call assert_equal(#{rc_one: 'one', rc: '.gvimrc'}, g:) |
| 226 | + call writefile(v:errors, 'Xresult') |
| 227 | + quit |
| 228 | + END |
| 229 | + call writefile(lines, 'Xscript', 'D') |
| 230 | + call system($'{vimcmd} -S Xscript') |
| 231 | + call assert_equal([], readfile('Xresult')) |
| 232 | + |
| 233 | + call delete(rc1) |
| 234 | + |
| 235 | + " Test for ~/.vim/gvimrc |
| 236 | + let lines =<< trim END |
| 237 | + " Ignore the "failed to create input context" error. |
| 238 | + call test_ignore_error('E285') |
| 239 | + gui -f |
| 240 | + call assert_match('Xhome/\.vim/gvimrc', $MYGVIMRC) |
| 241 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 242 | + call assert_equal(#{rc_two: 'two', rc: '.vim/gvimrc'}, g:) |
| 243 | + call writefile(v:errors, 'Xresult') |
| 244 | + quit |
| 245 | + END |
| 246 | + call writefile(lines, 'Xscript', 'D') |
| 247 | + call system($'{vimcmd} -S Xscript') |
| 248 | + call assert_equal([], readfile('Xresult')) |
| 249 | + |
| 250 | + call delete(rc2) |
| 251 | + |
| 252 | + " XDG_CONFIG_HOME is set in Github CI runners |
| 253 | + unlet $XDG_CONFIG_HOME |
| 254 | + |
| 255 | + " Test for ~/.config/vim/gvimrc |
| 256 | + let lines =<< trim END |
| 257 | + " Ignore the "failed to create input context" error. |
| 258 | + call test_ignore_error('E285') |
| 259 | + gui -f |
| 260 | + let msg = $'HOME="{$HOME}", ~="{expand("~")}"' |
| 261 | + call assert_match('Xhome/\.config/vim/gvimrc', $MYGVIMRC, msg) |
| 262 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 263 | + call assert_equal(#{rc_three: 'three', rc: '.config/vim/gvimrc'}, g:) |
| 264 | + call writefile(v:errors, 'Xresult') |
| 265 | + quit |
| 266 | + END |
| 267 | + call writefile(lines, 'Xscript', 'D') |
| 268 | + call system($'{vimcmd} -S Xscript') |
| 269 | + call assert_equal([], readfile('Xresult')) |
| 270 | + |
| 271 | + call delete(rc3) |
| 272 | + |
| 273 | + " Test for ~/xdg/vim/gvimrc |
| 274 | + let $XDG_CONFIG_HOME=expand('~/xdg/') |
| 275 | + let lines =<< trim END |
| 276 | + " Ignore the "failed to create input context" error. |
| 277 | + call test_ignore_error('E285') |
| 278 | + gui -f |
| 279 | + let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"' |
| 280 | + call assert_match('Xhome/xdg/vim/gvimrc', $MYGVIMRC, msg) |
| 281 | + call filter(g:, {idx, _ -> idx =~ '^rc'}) |
| 282 | + call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/gvimrc'}, g:) |
| 283 | + call writefile(v:errors, 'Xresult') |
| 284 | + quit |
| 285 | + END |
| 286 | + call writefile(lines, 'Xscript', 'D') |
| 287 | + call system($'{vimcmd} -S Xscript') |
| 288 | + call assert_equal([], readfile('Xresult')) |
| 289 | + |
| 290 | + call delete(rc4) |
| 291 | + |
| 292 | + " Clean up |
158 | 293 | unlet $XDG_CONFIG_HOME
|
| 294 | + call GUITearDownCommon() |
| 295 | + call delete('Xhome', 'rf') |
159 | 296 | endfunc
|
160 | 297 |
|
161 | 298 | " vim: shiftwidth=2 sts=2 expandtab
|
0 commit comments