blob: 047bc34a2f2541b055422a11f77d8ea398b45cd0 [file] [log] [blame]
Bram Moolenaar66459b72016-08-06 19:01:55 +02001" Tests for startup.
Bram Moolenaarb9a46fe2016-07-29 18:13:42 +02002
Bram Moolenaar66459b72016-08-06 19:01:55 +02003source shared.vim
4
5" Check that loading startup.vim works.
Bram Moolenaarb9a46fe2016-07-29 18:13:42 +02006func Test_startup_script()
7 set compatible
8 source $VIMRUNTIME/defaults.vim
9
10 call assert_equal(0, &compatible)
11endfunc
Bram Moolenaar66459b72016-08-06 19:01:55 +020012
13" Verify the order in which plugins are loaded:
14" 1. plugins in non-after directories
15" 2. packages
16" 3. plugins in after directories
17func Test_after_comes_later()
Bram Moolenaar32860432016-08-06 19:24:23 +020018 if !has('packages')
19 return
20 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020021 let before = [
22 \ 'let $HOME = "/does/not/exist"',
23 \ 'set loadplugins',
24 \ 'set rtp=Xhere,Xafter',
25 \ 'set packpath=Xhere,Xafter',
26 \ 'set nomore',
27 \ ]
28 let after = [
29 \ 'redir! > Xtestout',
30 \ 'scriptnames',
31 \ 'redir END',
32 \ 'quit',
33 \ ]
34 call mkdir('Xhere/plugin', 'p')
35 call writefile(['let done = 1'], 'Xhere/plugin/here.vim')
36 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
37 call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
38
39 call mkdir('Xafter/plugin', 'p')
40 call writefile(['let done = 1'], 'Xafter/plugin/later.vim')
41
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020042 if RunVim(before, after)
Bram Moolenaar66459b72016-08-06 19:01:55 +020043
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020044 let lines = readfile('Xtestout')
45 let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
46 let found = []
47 for line in lines
48 for one in expected
49 if line =~ one
50 call add(found, one)
51 endif
52 endfor
Bram Moolenaar66459b72016-08-06 19:01:55 +020053 endfor
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020054 call assert_equal(expected, found)
55 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020056
57 call delete('Xtestout')
58 call delete('Xhere', 'rf')
59 call delete('Xafter', 'rf')
60endfunc