Skip to content

Commit 1fbfe7c

Browse files
committed
patch 8.1.0131: :profdel is not tested
Problem: :profdel is not tested. Solution: Add a test. (Dominique Pelle, closes #3123)
1 parent ad64809 commit 1fbfe7c

File tree

2 files changed

+87
-15
lines changed

2 files changed

+87
-15
lines changed

Diff for: src/testdir/test_profile.vim

+85-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ endif
55

66
func Test_profile_func()
77
let lines = [
8+
\ 'profile start Xprofile_func.log',
9+
\ 'profile func Foo*"',
810
\ "func! Foo1()",
911
\ "endfunc",
1012
\ "func! Foo2()",
@@ -33,9 +35,7 @@ func Test_profile_func()
3335

3436
call writefile(lines, 'Xprofile_func.vim')
3537
call system(v:progpath
36-
\ . ' -es -u NONE -U NONE -i NONE --noplugin'
37-
\ . ' -c "profile start Xprofile_func.log"'
38-
\ . ' -c "profile func Foo*"'
38+
\ . ' -es --clean'
3939
\ . ' -c "so Xprofile_func.vim"'
4040
\ . ' -c "qall!"')
4141
call assert_equal(0, v:shell_error)
@@ -97,7 +97,7 @@ func Test_profile_file()
9797

9898
call writefile(lines, 'Xprofile_file.vim')
9999
call system(v:progpath
100-
\ . ' -es -u NONE -U NONE -i NONE --noplugin'
100+
\ . ' -es --clean'
101101
\ . ' -c "profile start Xprofile_file.log"'
102102
\ . ' -c "profile file Xprofile_file.vim"'
103103
\ . ' -c "so Xprofile_file.vim"'
@@ -152,17 +152,17 @@ func Test_profile_file_with_cont()
152152
let lines = readfile('Xprofile_file.log')
153153
call assert_equal(11, len(lines))
154154

155-
call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
156-
call assert_equal('Sourced 1 time', lines[1])
157-
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
158-
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
159-
call assert_equal('', lines[4])
160-
call assert_equal('count total (s) self (s)', lines[5])
161-
call assert_match(' 1 0.\d\+ echo "hello', lines[6])
162-
call assert_equal(' \ world"', lines[7])
163-
call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
164-
call assert_equal(' \bar"', lines[9])
165-
call assert_equal('', lines[10])
155+
call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
156+
call assert_equal('Sourced 1 time', lines[1])
157+
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
158+
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
159+
call assert_equal('', lines[4])
160+
call assert_equal('count total (s) self (s)', lines[5])
161+
call assert_match(' 1 0.\d\+ echo "hello', lines[6])
162+
call assert_equal(' \ world"', lines[7])
163+
call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
164+
call assert_equal(' \bar"', lines[9])
165+
call assert_equal('', lines[10])
166166

167167
call delete('Xprofile_file.vim')
168168
call delete('Xprofile_file.log')
@@ -222,3 +222,73 @@ func Test_profile_truncate_mbyte()
222222
call delete('Xprofile_file.vim')
223223
call delete('Xprofile_file.log')
224224
endfunc
225+
226+
func Test_profdel_func()
227+
let lines = [
228+
\ 'profile start Xprofile_file.log',
229+
\ 'func! Foo1()',
230+
\ 'endfunc',
231+
\ 'func! Foo2()',
232+
\ 'endfunc',
233+
\ 'func! Foo3()',
234+
\ 'endfunc',
235+
\ '',
236+
\ 'profile func Foo1',
237+
\ 'profile func Foo2',
238+
\ 'call Foo1()',
239+
\ 'call Foo2()',
240+
\ '',
241+
\ 'profile func Foo3',
242+
\ 'profdel func Foo2',
243+
\ 'profdel func Foo3',
244+
\ 'call Foo1()',
245+
\ 'call Foo2()',
246+
\ 'call Foo3()' ]
247+
call writefile(lines, 'Xprofile_file.vim')
248+
call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
249+
call assert_equal(0, v:shell_error)
250+
251+
let lines = readfile('Xprofile_file.log')
252+
call assert_equal(24, len(lines))
253+
254+
" Check that:
255+
" - Foo1() is called twice (profdel not invoked)
256+
" - Foo2() is called once (profdel invoked after it was called)
257+
" - Foo3() is not called (profdel invoked before it was called)
258+
call assert_equal('FUNCTION Foo1()', lines[0])
259+
call assert_equal('Called 2 times', lines[1])
260+
call assert_equal('FUNCTION Foo2()', lines[7])
261+
call assert_equal('Called 1 time', lines[8])
262+
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[14])
263+
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[19])
264+
265+
call delete('Xprofile_file.vim')
266+
call delete('Xprofile_file.log')
267+
endfunc
268+
269+
func Test_profdel_star()
270+
" Foo() is invoked once before and once after 'profdel *'.
271+
" So profiling should report it only once.
272+
let lines = [
273+
\ 'profile start Xprofile_file.log',
274+
\ 'func! Foo()',
275+
\ 'endfunc',
276+
\ 'profile func Foo',
277+
\ 'call Foo()',
278+
\ 'profdel *',
279+
\ 'call Foo()' ]
280+
call writefile(lines, 'Xprofile_file.vim')
281+
call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
282+
call assert_equal(0, v:shell_error)
283+
284+
let lines = readfile('Xprofile_file.log')
285+
call assert_equal(15, len(lines))
286+
287+
call assert_equal('FUNCTION Foo()', lines[0])
288+
call assert_equal('Called 1 time', lines[1])
289+
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[7])
290+
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[11])
291+
292+
call delete('Xprofile_file.vim')
293+
call delete('Xprofile_file.log')
294+
endfunc

Diff for: src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ static char *(features[]) =
789789

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
131,
792794
/**/
793795
130,
794796
/**/

0 commit comments

Comments
 (0)