@@ -4,16 +4,13 @@ if !has('profile')
44endif
55
66func Test_profile_func ()
7- if ! has (' unix' )
8- return
9- endif
107 let lines = [
118 \ " func! Foo1()" ,
129 \ " endfunc" ,
1310 \ " func! Foo2()" ,
14- \ " let count = 100" ,
15- \ " while count > 0" ,
16- \ " let count = count - 1" ,
11+ \ " let l: count = 100" ,
12+ \ " while l: count > 0" ,
13+ \ " let l: count = l: count - 1" ,
1714 \ " endwhile" ,
1815 \ " endfunc" ,
1916 \ " func! Foo3()" ,
@@ -35,47 +32,59 @@ func Test_profile_func()
3532 \ ]
3633
3734 call writefile (lines , ' Xprofile_func.vim' )
38- let a = system (v: progpath
39- \ . " -u NONE -i NONE --noplugin"
40- \ . " -c 'profile start Xprofile_func.log'"
41- \ . " -c 'profile func Foo*'"
42- \ . " -c 'so Xprofile_func.vim'"
43- \ . " -c 'qall!'" )
44- let lines = readfile (' Xprofile_func.log' )
45-
46- call assert_equal (28 , len (lines ))
35+ 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*"'
39+ \ . ' -c "so Xprofile_func.vim"'
40+ \ . ' -c "qall!"' )
41+ call assert_equal (0 , v: shell_error )
4742
48- call assert_equal (' FUNCTION Foo1()' , lines [0 ])
49- call assert_equal (' Called 2 times' , lines [1 ])
50- call assert_equal (' FUNCTION Foo2()' , lines [7 ])
51- call assert_equal (' Called 1 time' , lines [8 ])
43+ let lines = readfile (' Xprofile_func.log' )
5244
5345 " - Foo1() is called 3 times but should be reported as called twice
5446 " since one call is in between "profile pause" .. "profile continue".
55- " - Foo2() should come before Foo1() since Foo1() does much more work.\
47+ " - Foo2() should come before Foo1() since Foo1() does much more work.
5648 " - Foo3() is not reported because function is deleted.
5749 " - Unlike Foo3(), Foo2() should not be deleted since there is a check
5850 " for v:profiling.
5951 " - Bar() is not reported since it does not match "profile func Foo*".
60- call assert_equal (' FUNCTIONS SORTED ON TOTAL TIME' , lines [18 ])
61- call assert_equal (' count total (s) self (s) function' , lines [19 ])
62- call assert_match (' ^\s*1\s\+\d\+\.\d\+\s\+Foo2()$' , lines [20 ])
63- call assert_match (' ^\s*2\s\+\d\+\.\d\+\s\+Foo1()$' , lines [21 ])
64- call assert_equal (' ' , lines [22 ])
65- call assert_equal (' FUNCTIONS SORTED ON SELF TIME' , lines [23 ])
66- call assert_equal (' count total (s) self (s) function' , lines [24 ])
67- call assert_match (' ^\s*1\s\+\d\+\.\d\+\s\+Foo2()$' , lines [25 ])
68- call assert_match (' ^\s*2\s\+\d\+\.\d\+\s\+Foo1()$' , lines [26 ])
69- call assert_equal (' ' , lines [27 ])
52+ call assert_equal (28 , len (lines ))
53+
54+ call assert_equal (' FUNCTION Foo1()' , lines [0 ])
55+ call assert_equal (' Called 2 times' , lines [1 ])
56+ call assert_match (' ^Total time:\s\+\d\+\.\d\+$' , lines [2 ])
57+ call assert_match (' ^ Self time:\s\+\d\+\.\d\+$' , lines [3 ])
58+ call assert_equal (' ' , lines [4 ])
59+ call assert_equal (' count total (s) self (s)' , lines [5 ])
60+ call assert_equal (' ' , lines [6 ])
61+ call assert_equal (' FUNCTION Foo2()' , lines [7 ])
62+ call assert_equal (' Called 1 time' , lines [8 ])
63+ call assert_match (' ^Total time:\s\+\d\+\.\d\+$' , lines [9 ])
64+ call assert_match (' ^ Self time:\s\+\d\+\.\d\+$' , lines [10 ])
65+ call assert_equal (' ' , lines [11 ])
66+ call assert_equal (' count total (s) self (s)' , lines [12 ])
67+ call assert_match (' ^\s*1\s\+.*\slet l:count = 100$' , lines [13 ])
68+ call assert_match (' ^\s*101\s\+.*\swhile l:count > 0$' , lines [14 ])
69+ call assert_match (' ^\s*100\s\+.*\s let l:count = l:count - 1$' , lines [15 ])
70+ call assert_match (' ^\s*100\s\+.*\sendwhile$' , lines [16 ])
71+ call assert_equal (' ' , lines [17 ])
72+ call assert_equal (' FUNCTIONS SORTED ON TOTAL TIME' , lines [18 ])
73+ call assert_equal (' count total (s) self (s) function' , lines [19 ])
74+ call assert_match (' ^\s*1\s\+\d\+\.\d\+\s\+Foo2()$' , lines [20 ])
75+ call assert_match (' ^\s*2\s\+\d\+\.\d\+\s\+Foo1()$' , lines [21 ])
76+ call assert_equal (' ' , lines [22 ])
77+ call assert_equal (' FUNCTIONS SORTED ON SELF TIME' , lines [23 ])
78+ call assert_equal (' count total (s) self (s) function' , lines [24 ])
79+ call assert_match (' ^\s*1\s\+\d\+\.\d\+\s\+Foo2()$' , lines [25 ])
80+ call assert_match (' ^\s*2\s\+\d\+\.\d\+\s\+Foo1()$' , lines [26 ])
81+ call assert_equal (' ' , lines [27 ])
7082
7183 call delete (' Xprofile_func.vim' )
7284 call delete (' Xprofile_func.log' )
7385endfunc
7486
7587func Test_profile_file ()
76- if ! has (' unix' )
77- return
78- endif
7988 let lines = [
8089 \ ' func! Foo()' ,
8190 \ ' endfunc' ,
@@ -87,13 +96,14 @@ func Test_profile_file()
8796 \ ]
8897
8998 call writefile (lines , ' Xprofile_file.vim' )
90- let a = system (v: progpath
91- \ . " -u NONE -i NONE --noplugin"
92- \ . " -c 'profile start Xprofile_file.log'"
93- \ . " -c 'profile file Xprofile_file.vim'"
94- \ . " -c 'so Xprofile_file.vim'"
95- \ . " -c 'so Xprofile_file.vim'"
96- \ . " -c 'qall!'" )
99+ call system (v: progpath
100+ \ . ' -es -u NONE -U NONE -i NONE --noplugin'
101+ \ . ' -c "profile start Xprofile_file.log"'
102+ \ . ' -c "profile file Xprofile_file.vim"'
103+ \ . ' -c "so Xprofile_file.vim"'
104+ \ . ' -c "so Xprofile_file.vim"'
105+ \ . ' -c "qall!"' )
106+ call assert_equal (0 , v: shell_error )
97107
98108 let lines = readfile (' Xprofile_file.log' )
99109
0 commit comments