blob: da6a3f6f80983042d7be1a0e65e20a848fbbd187 [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()
18 let before = [
19 \ 'let $HOME = "/does/not/exist"',
20 \ 'set loadplugins',
21 \ 'set rtp=Xhere,Xafter',
22 \ 'set packpath=Xhere,Xafter',
23 \ 'set nomore',
24 \ ]
25 let after = [
26 \ 'redir! > Xtestout',
27 \ 'scriptnames',
28 \ 'redir END',
29 \ 'quit',
30 \ ]
31 call mkdir('Xhere/plugin', 'p')
32 call writefile(['let done = 1'], 'Xhere/plugin/here.vim')
33 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
34 call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
35
36 call mkdir('Xafter/plugin', 'p')
37 call writefile(['let done = 1'], 'Xafter/plugin/later.vim')
38
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020039 if RunVim(before, after)
Bram Moolenaar66459b72016-08-06 19:01:55 +020040
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020041 let lines = readfile('Xtestout')
42 let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
43 let found = []
44 for line in lines
45 for one in expected
46 if line =~ one
47 call add(found, one)
48 endif
49 endfor
Bram Moolenaar66459b72016-08-06 19:01:55 +020050 endfor
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020051 call assert_equal(expected, found)
52 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020053
54 call delete('Xtestout')
55 call delete('Xhere', 'rf')
56 call delete('Xafter', 'rf')
57endfunc