" Tests for startup.
source shared.vim
source screendump.vim
source term_util.vim
source check.vim
" Check that loading startup.vim works.
func Test_startup_script()
set compatible
source $VIMRUNTIME/defaults.vim
call assert_equal(0, &compatible)
" Restore some options, so that the following tests doesn't break
set nomore
set noshowmode
endfunc
" Verify the order in which plugins are loaded:
" 1. plugins in non-after directories
" 2. packages
" 3. plugins in after directories
func Test_after_comes_later()
CheckFeature packages
let before =<< trim [CODE]
set nocp viminfo+=nviminfo
set guioptions+=M
let $HOME = "/does/not/exist"
set loadplugins
set rtp=Xhere,Xafter,Xanother
set packpath=Xhere,Xafter
set nomore
let g:sequence = ""
[CODE]
let after =<< trim [CODE]
redir! > Xtestout
scriptnames
redir END
redir! > Xsequence
echo g:sequence
redir END
quit
[CODE]
call mkdir('Xhere/plugin', 'p')
call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
call mkdir('Xanother/plugin', 'p')
call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim')
call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
call mkdir('Xafter/plugin', 'p')
call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim')
if RunVim(before, after, '')
let lines = readfile('Xtestout')
let expected = ['Xbefore.vim', 'here.vim', 'another.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
let found = []
for line in lines
for one in expected
if line =~ one
call add(found, one)
endif
endfor
endfor
call assert_equal(expected, found)
endif
call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', ''))
call delete('Xtestout')
call delete('Xsequence')
call delete('Xhere', 'rf')
call delete('Xanother', 'rf')
call delete('Xafter', 'rf')
endfunc
func Test_pack_in_rtp_when_plugins_run()
CheckFeature packages
let before =<< trim [CODE]
set nocp viminfo+=nviminfo
set guioptions+=M
let $HOME = "/does/not/exist"
set loadplugins
set rtp=Xhere
set packpath=Xhere
set nomore
[CODE]
let after = [
\ 'quit',
\ ]
call mkdir('Xhere/plugin', 'p')
call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim')
call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p')
call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim')
if RunVim(before, after, '')
let lines = filter(readfile('Xtestout'), '!empty(v:val)')
call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0))
call assert_match('autoloaded foo', get(lines, 1))
endif