Skip to content

Commit

Permalink
patch 9.0.1398: profile test repeats the headers many times
Browse files Browse the repository at this point in the history
Problem:    Profile test repeats the headers many times.
Solution:   Put the headers in script variables.
  • Loading branch information
brammool committed Mar 10, 2023
1 parent 6a7c774 commit c0bdbfb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/testdir/test_profile.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CheckFeature profile
source shared.vim
source screendump.vim

let s:header = 'count total (s) self (s)'
let s:header_func = 'count total (s) self (s) function'

func Test_profile_func()
call RunProfileFunc('func', 'let', 'let')
call RunProfileFunc('def', 'var', '')
Expand Down Expand Up @@ -71,27 +74,27 @@ func RunProfileFunc(command, declare, assign)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
call assert_equal('', lines[5])
call assert_equal('count total (s) self (s)', lines[6])
call assert_equal(s:header, lines[6])
call assert_equal('', lines[7])
call assert_equal('FUNCTION Foo2()', lines[8])
call assert_equal('Called 1 time', lines[10])
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[11])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[12])
call assert_equal('', lines[13])
call assert_equal('count total (s) self (s)', lines[14])
call assert_equal(s:header, lines[14])
call assert_match('^\s*1\s\+.*\s\(let\|var\) counter = 100$', lines[15])
call assert_match('^\s*101\s\+.*\swhile counter > 0$', lines[16])
call assert_match('^\s*100\s\+.*\s \(let\)\= counter = counter - 1$', lines[17])
call assert_match('^\s*10[01]\s\+.*\sendwhile$', lines[18])
call assert_match('^\s*1\s\+.\+sleep 1m$', lines[19])
call assert_equal('', lines[20])
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[21])
call assert_equal('count total (s) self (s) function', lines[22])
call assert_equal(s:header_func, lines[22])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[23])
call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[24])
call assert_equal('', lines[25])
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[26])
call assert_equal('count total (s) self (s) function', lines[27])
call assert_equal(s:header_func, lines[27])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[28])
call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[29])
call assert_equal('', lines[30])
Expand Down Expand Up @@ -163,7 +166,7 @@ func Run_profile_func_with_ifelse(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
call assert_equal('', lines[5])
call assert_equal('count total (s) self (s)', lines[6])
call assert_equal(s:header, lines[6])
call assert_match('^\s*1\s\+.*\sif 1$', lines[7])
call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
call assert_match( '^\s\+elseif 1$', lines[9])
Expand All @@ -177,7 +180,7 @@ func Run_profile_func_with_ifelse(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
call assert_equal('', lines[20])
call assert_equal('count total (s) self (s)', lines[21])
call assert_equal(s:header, lines[21])
call assert_match('^\s*1\s\+.*\sif 0$', lines[22])
call assert_match( '^\s\+\(let\|var\) x = 0$', lines[23])
call assert_match('^\s*1\s\+.*\selseif 1$', lines[24])
Expand All @@ -191,7 +194,7 @@ func Run_profile_func_with_ifelse(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
call assert_equal('', lines[35])
call assert_equal('count total (s) self (s)', lines[36])
call assert_equal(s:header, lines[36])
call assert_match('^\s*1\s\+.*\sif 0$', lines[37])
call assert_match( '^\s\+\(let\|var\) x = 0$', lines[38])
call assert_match('^\s*1\s\+.*\selseif 0$', lines[39])
Expand All @@ -201,13 +204,13 @@ func Run_profile_func_with_ifelse(command, declare)
call assert_match('^\s*1\s\+.*\sendif$', lines[43])
call assert_equal('', lines[44])
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
call assert_equal('count total (s) self (s) function', lines[46])
call assert_equal(s:header_func, lines[46])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
call assert_equal('', lines[50])
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
call assert_equal('count total (s) self (s) function', lines[52])
call assert_equal(s:header_func, lines[52])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
Expand Down Expand Up @@ -289,7 +292,7 @@ func Run_profile_func_with_trycatch(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
call assert_equal('', lines[5])
call assert_equal('count total (s) self (s)', lines[6])
call assert_equal(s:header, lines[6])
call assert_match('^\s*1\s\+.*\stry$', lines[7])
call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
call assert_match( '^\s\+catch$', lines[9])
Expand All @@ -303,7 +306,7 @@ func Run_profile_func_with_trycatch(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
call assert_equal('', lines[20])
call assert_equal('count total (s) self (s)', lines[21])
call assert_equal(s:header, lines[21])
call assert_match('^\s*1\s\+.*\stry$', lines[22])
call assert_match('^\s*1\s\+.*\s throw 0$', lines[23])
call assert_match('^\s*1\s\+.*\scatch$', lines[24])
Expand All @@ -317,7 +320,7 @@ func Run_profile_func_with_trycatch(command, declare)
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
call assert_equal('', lines[35])
call assert_equal('count total (s) self (s)', lines[36])
call assert_equal(s:header, lines[36])
call assert_match('^\s*1\s\+.*\stry$', lines[37])
call assert_match('^\s*1\s\+.*\s throw 0$', lines[38])
call assert_match('^\s*1\s\+.*\scatch$', lines[39])
Expand All @@ -327,13 +330,13 @@ func Run_profile_func_with_trycatch(command, declare)
call assert_match( '^\s\+endtry$', lines[43])
call assert_equal('', lines[44])
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
call assert_equal('count total (s) self (s) function', lines[46])
call assert_equal(s:header_func, lines[46])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
call assert_equal('', lines[50])
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
call assert_equal('count total (s) self (s) function', lines[52])
call assert_equal(s:header_func, lines[52])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
Expand Down Expand Up @@ -372,7 +375,7 @@ func Test_profile_file()
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
call assert_equal('', lines[4])
call assert_equal('count total (s) self (s)', lines[5])
call assert_equal(s:header, lines[5])
call assert_match(' 2 0.\d\+ func! Foo()', lines[6])
call assert_equal(' endfunc', lines[7])
" Loop iterates 10 times. Since script runs twice, body executes 20 times.
Expand Down Expand Up @@ -414,7 +417,7 @@ func Test_profile_file_with_cont()
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
call assert_equal('', lines[4])
call assert_equal('count total (s) self (s)', lines[5])
call assert_equal(s:header, lines[5])
call assert_match(' 1 0.\d\+ echo "hello', lines[6])
call assert_equal(' \ world"', lines[7])
call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
Expand Down Expand Up @@ -450,15 +453,15 @@ func Test_profile_stop_dump()
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
call assert_equal('', lines[5])
call assert_equal('count total (s) self (s)', lines[6])
call assert_equal(s:header, lines[6])
call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
call assert_equal('', lines[8])
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
call assert_equal('count total (s) self (s) function', lines[10])
call assert_equal(s:header_func, lines[10])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
call assert_equal('', lines[12])
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
call assert_equal('count total (s) self (s) function', lines[14])
call assert_equal(s:header_func, lines[14])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
call assert_equal('', lines[16])

Expand All @@ -475,15 +478,15 @@ func Test_profile_stop_dump()
call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
call assert_equal('', lines[5])
call assert_equal('count total (s) self (s)', lines[6])
call assert_equal(s:header, lines[6])
call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[7])
call assert_equal('', lines[8])
call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
call assert_equal('count total (s) self (s) function', lines[10])
call assert_equal(s:header_func, lines[10])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[11])
call assert_equal('', lines[12])
call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
call assert_equal('count total (s) self (s) function', lines[14])
call assert_equal(s:header_func, lines[14])
call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[15])
call assert_equal('', lines[16])

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1398,
/**/
1397,
/**/
Expand Down

0 comments on commit c0bdbfb

Please sign in to comment.