comparison src/testdir/test_startup.vim @ 9804:4ef933b816e7 v7.4.2177

commit https://github.com/vim/vim/commit/ba98bef1910094179bf90b9467b6e2d2f9462601 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 7 15:51:39 2016 +0200 patch 7.4.2177 Problem: No testing for -C and -N command line flags, file arguments, startuptime. Solution: Add tests.
author Christian Brabandt <cb@256bit.org>
date Sun, 07 Aug 2016 16:00:05 +0200
parents 1f1ed7959860
children 108b62925cb0
comparison
equal deleted inserted replaced
9803:a07f3bc60f7f 9804:4ef933b816e7
67 return 67 return
68 endif 68 endif
69 if RunVim([], [], '--help >Xtestout') 69 if RunVim([], [], '--help >Xtestout')
70 let lines = readfile('Xtestout') 70 let lines = readfile('Xtestout')
71 call assert_true(len(lines) > 20) 71 call assert_true(len(lines) > 20)
72 call assert_true(lines[0] =~ 'Vi IMproved') 72 call assert_match('Vi IMproved', lines[0])
73 73
74 " check if couple of lines are there 74 " check if couple of lines are there
75 let found = 0 75 let found = 0
76 for line in lines 76 for line in lines
77 if line =~ '-R.*Readonly mode' 77 if line =~ '-R.*Readonly mode'
83 endfor 83 endfor
84 call assert_equal(2, found) 84 call assert_equal(2, found)
85 endif 85 endif
86 call delete('Xtestout') 86 call delete('Xtestout')
87 endfunc 87 endfunc
88
89 func Test_compatible_args()
90 let after = [
91 \ 'call writefile([string(&compatible)], "Xtestout")',
92 \ 'set viminfo+=nviminfo',
93 \ 'quit',
94 \ ]
95 if RunVim([], after, '-C')
96 let lines = readfile('Xtestout')
97 call assert_equal('1', lines[0])
98 endif
99
100 if RunVim([], after, '-N')
101 let lines = readfile('Xtestout')
102 call assert_equal('0', lines[0])
103 endif
104
105 call delete('Xtestout')
106 endfunc
107
108 func Test_file_args()
109 let after = [
110 \ 'call writefile(argv(), "Xtestout")',
111 \ 'qall',
112 \ ]
113 if RunVim([], after, '')
114 let lines = readfile('Xtestout')
115 call assert_equal(0, len(lines))
116 endif
117
118 if RunVim([], after, 'one')
119 let lines = readfile('Xtestout')
120 call assert_equal(1, len(lines))
121 call assert_equal('one', lines[0])
122 endif
123
124 if RunVim([], after, 'one two three')
125 let lines = readfile('Xtestout')
126 call assert_equal(3, len(lines))
127 call assert_equal('one', lines[0])
128 call assert_equal('two', lines[1])
129 call assert_equal('three', lines[2])
130 endif
131
132 if RunVim([], after, 'one -c echo two')
133 let lines = readfile('Xtestout')
134 call assert_equal(2, len(lines))
135 call assert_equal('one', lines[0])
136 call assert_equal('two', lines[1])
137 endif
138
139 if RunVim([], after, 'one -- -c echo two')
140 let lines = readfile('Xtestout')
141 call assert_equal(4, len(lines))
142 call assert_equal('one', lines[0])
143 call assert_equal('-c', lines[1])
144 call assert_equal('echo', lines[2])
145 call assert_equal('two', lines[3])
146 endif
147
148 call delete('Xtestout')
149 endfunc
150
151 func Test_startuptime()
152 if !has('startuptime')
153 return
154 endif
155 let after = ['qall']
156 if RunVim([], after, '--startuptime Xtestout one')
157 let lines = readfile('Xtestout')
158 let expected = ['--- VIM STARTING ---', 'parsing arguments',
159 \ 'shell init', 'inits 3', 'start termcap', 'opening buffers']
160 let found = []
161 for line in lines
162 for exp in expected
163 if line =~ exp
164 call add(found, exp)
165 endif
166 endfor
167 endfor
168 call assert_equal(expected, found)
169 endif
170 call delete('Xtestout')
171 endfunc