Skip to content

Commit ba98bef

Browse files
committed
patch 7.4.2177
Problem: No testing for -C and -N command line flags, file arguments, startuptime. Solution: Add tests.
1 parent a8e691d commit ba98bef

3 files changed

Lines changed: 89 additions & 3 deletions

File tree

src/testdir/shared.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func RunVim(before, after, arguments)
130130
if !filereadable('vimcmd')
131131
return 0
132132
endif
133-
let args = a:arguments
133+
let args = ''
134134
if len(a:before) > 0
135135
call writefile(a:before, 'Xbefore.vim')
136136
let args .= ' --cmd "so Xbefore.vim"'
@@ -145,7 +145,7 @@ func RunVim(before, after, arguments)
145145
if cmd !~ '-u NONE'
146146
let cmd = cmd . ' -u NONE'
147147
endif
148-
exe "silent !" . cmd . ' ' . args
148+
exe "silent !" . cmd . args . ' ' . a:arguments
149149

150150
if len(a:before) > 0
151151
call delete('Xbefore.vim')

src/testdir/test_startup.vim

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Test_help_arg()
6969
if RunVim([], [], '--help >Xtestout')
7070
let lines = readfile('Xtestout')
7171
call assert_true(len(lines) > 20)
72-
call assert_true(lines[0] =~ 'Vi IMproved')
72+
call assert_match('Vi IMproved', lines[0])
7373

7474
" check if couple of lines are there
7575
let found = 0
@@ -85,3 +85,87 @@ func Test_help_arg()
8585
endif
8686
call delete('Xtestout')
8787
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

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2177,
766768
/**/
767769
2176,
768770
/**/

0 commit comments

Comments
 (0)