blob: d2463f476dc72ad12706c4ea223f0ebd3be7cef5 [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 = [
Bram Moolenaar446cce62016-08-06 21:37:27 +020022 \ 'set nocp viminfo+=nviminfo',
23 \ 'set guioptions+=M',
Bram Moolenaar66459b72016-08-06 19:01:55 +020024 \ 'let $HOME = "/does/not/exist"',
25 \ 'set loadplugins',
26 \ 'set rtp=Xhere,Xafter',
27 \ 'set packpath=Xhere,Xafter',
28 \ 'set nomore',
29 \ ]
30 let after = [
31 \ 'redir! > Xtestout',
32 \ 'scriptnames',
33 \ 'redir END',
34 \ 'quit',
35 \ ]
36 call mkdir('Xhere/plugin', 'p')
37 call writefile(['let done = 1'], 'Xhere/plugin/here.vim')
38 call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
39 call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
40
41 call mkdir('Xafter/plugin', 'p')
42 call writefile(['let done = 1'], 'Xafter/plugin/later.vim')
43
Bram Moolenaar472a0a82016-08-06 22:31:42 +020044 if RunVim(before, after, '')
Bram Moolenaar66459b72016-08-06 19:01:55 +020045
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020046 let lines = readfile('Xtestout')
47 let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim']
48 let found = []
49 for line in lines
50 for one in expected
51 if line =~ one
52 call add(found, one)
53 endif
54 endfor
Bram Moolenaar66459b72016-08-06 19:01:55 +020055 endfor
Bram Moolenaar83b3c3d2016-08-06 19:16:43 +020056 call assert_equal(expected, found)
57 endif
Bram Moolenaar66459b72016-08-06 19:01:55 +020058
59 call delete('Xtestout')
60 call delete('Xhere', 'rf')
61 call delete('Xafter', 'rf')
62endfunc
Bram Moolenaar472a0a82016-08-06 22:31:42 +020063
64func Test_help_arg()
65 if RunVim([], [], '--help >Xtestout')
66 let lines = readfile('Xtestout')
67 call assert_true(len(lines) > 20)
68 call assert_true(lines[0] =~ 'Vi IMproved')
69
70 " check if couple of lines are there
71 let found = 0
72 for line in lines
73 if line =~ '-R.*Readonly mode'
74 let found += 1
75 endif
76 if line =~ '--version'
77 let found += 1
78 endif
79 endfor
80 call assert_equal(2, found)
81 endif
82 call delete('Xtestout')
83endfunc