annotate src/testdir/test_profile.vim @ 17698:131f1d8c5860 v8.1.1846

patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath commit https://github.com/vim/vim/commit/93344c2d707d9953f351c944e6a237c9916f69a3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 14 21:12:05 2019 +0200 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath Problem: Inconsistently using GetVimCommand() and v:progpath. (Daniel Hahler) Solution: Use GetVimCommand(). (closes #4806)
author Bram Moolenaar <Bram@vim.org>
date Wed, 14 Aug 2019 21:15:06 +0200
parents 6990c1160ea5
children 48fd0712dad8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test Vim profiler
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
3 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 CheckFeature profile
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
6 source shared.vim
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
7
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_profile_func()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
9 let lines =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
10 profile start Xprofile_func.log
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
11 profile func Foo*
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
12 func! Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
13 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
14 func! Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
15 let l:count = 100
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
16 while l:count > 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
17 let l:count = l:count - 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
18 endwhile
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
19 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
20 func! Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
21 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
22 func! Bar()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
23 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
24 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
25 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
26 profile pause
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
27 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
28 profile continue
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
29 call Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
30 call Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
31 call Bar()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
32 if !v:profiling
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
33 delfunc Foo2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
34 endif
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
35 delfunc Foo3
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
36 [CODE]
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call writefile(lines, 'Xprofile_func.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
39 call system(GetVimCommand()
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
40 \ . ' -es --clean'
10613
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
41 \ . ' -c "so Xprofile_func.vim"'
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
42 \ . ' -c "qall!"')
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
43 call assert_equal(0, v:shell_error)
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
44
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 let lines = readfile('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " - Foo1() is called 3 times but should be reported as called twice
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " since one call is in between "profile pause" .. "profile continue".
10613
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
49 " - Foo2() should come before Foo1() since Foo1() does much more work.
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 " - Foo3() is not reported because function is deleted.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " - Unlike Foo3(), Foo2() should not be deleted since there is a check
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 " for v:profiling.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " - Bar() is not reported since it does not match "profile func Foo*".
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
54 call assert_equal(30, len(lines))
10613
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
55
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
56 call assert_equal('FUNCTION Foo1()', lines[0])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
57 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
58 call assert_equal('Called 2 times', lines[2])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
59 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
60 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
61 call assert_equal('', lines[5])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
62 call assert_equal('count total (s) self (s)', lines[6])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
63 call assert_equal('', lines[7])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
64 call assert_equal('FUNCTION Foo2()', lines[8])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
65 call assert_equal('Called 1 time', lines[10])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
66 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[11])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
67 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[12])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
68 call assert_equal('', lines[13])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
69 call assert_equal('count total (s) self (s)', lines[14])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
70 call assert_match('^\s*1\s\+.*\slet l:count = 100$', lines[15])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
71 call assert_match('^\s*101\s\+.*\swhile l:count > 0$', lines[16])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
72 call assert_match('^\s*100\s\+.*\s let l:count = l:count - 1$', lines[17])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
73 call assert_match('^\s*101\s\+.*\sendwhile$', lines[18])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
74 call assert_equal('', lines[19])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
75 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[20])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
76 call assert_equal('count total (s) self (s) function', lines[21])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
77 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[22])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
78 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[23])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
79 call assert_equal('', lines[24])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
80 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[25])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
81 call assert_equal('count total (s) self (s) function', lines[26])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
82 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[27])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
83 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[28])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
84 call assert_equal('', lines[29])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 call delete('Xprofile_func.vim')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 call delete('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
90 func Test_profile_func_with_ifelse()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
91 let lines =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
92 func! Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
93 if 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
94 let x = 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
95 elseif 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
96 let x = 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
97 else
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
98 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
99 endif
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
100 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
101 func! Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
102 if 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
103 let x = 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
104 elseif 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
105 let x = 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
106 else
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
107 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
108 endif
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
109 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
110 func! Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
111 if 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
112 let x = 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
113 elseif 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
114 let x = 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
115 else
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
116 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
117 endif
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
118 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
119 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
120 call Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
121 call Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
122 [CODE]
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
123
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
124 call writefile(lines, 'Xprofile_func.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
125 call system(GetVimCommand()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
126 \ . ' -es -i NONE --noplugin'
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
127 \ . ' -c "profile start Xprofile_func.log"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
128 \ . ' -c "profile func Foo*"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
129 \ . ' -c "so Xprofile_func.vim"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
130 \ . ' -c "qall!"')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
131 call assert_equal(0, v:shell_error)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
132
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
133 let lines = readfile('Xprofile_func.log')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
134
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
135 " - Foo1() should pass 'if' block.
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
136 " - Foo2() should pass 'elseif' block.
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
137 " - Foo3() should pass 'else' block.
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
138 call assert_equal(57, len(lines))
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
139
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
140 call assert_equal('FUNCTION Foo1()', lines[0])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
141 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
142 call assert_equal('Called 1 time', lines[2])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
143 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
144 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
145 call assert_equal('', lines[5])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
146 call assert_equal('count total (s) self (s)', lines[6])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
147 call assert_match('^\s*1\s\+.*\sif 1$', lines[7])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
148 call assert_match('^\s*1\s\+.*\s let x = 0$', lines[8])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
149 call assert_match( '^\s\+elseif 1$', lines[9])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
150 call assert_match( '^\s\+let x = 1$', lines[10])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
151 call assert_match( '^\s\+else$', lines[11])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
152 call assert_match( '^\s\+let x = 2$', lines[12])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
153 call assert_match('^\s*1\s\+.*\sendif$', lines[13])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
154 call assert_equal('', lines[14])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
155 call assert_equal('FUNCTION Foo2()', lines[15])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
156 call assert_equal('Called 1 time', lines[17])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
157 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
158 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
159 call assert_equal('', lines[20])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
160 call assert_equal('count total (s) self (s)', lines[21])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
161 call assert_match('^\s*1\s\+.*\sif 0$', lines[22])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
162 call assert_match( '^\s\+let x = 0$', lines[23])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
163 call assert_match('^\s*1\s\+.*\selseif 1$', lines[24])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
164 call assert_match('^\s*1\s\+.*\s let x = 1$', lines[25])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
165 call assert_match( '^\s\+else$', lines[26])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
166 call assert_match( '^\s\+let x = 2$', lines[27])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
167 call assert_match('^\s*1\s\+.*\sendif$', lines[28])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
168 call assert_equal('', lines[29])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
169 call assert_equal('FUNCTION Foo3()', lines[30])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
170 call assert_equal('Called 1 time', lines[32])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
171 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
172 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
173 call assert_equal('', lines[35])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
174 call assert_equal('count total (s) self (s)', lines[36])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
175 call assert_match('^\s*1\s\+.*\sif 0$', lines[37])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
176 call assert_match( '^\s\+let x = 0$', lines[38])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
177 call assert_match('^\s*1\s\+.*\selseif 0$', lines[39])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
178 call assert_match( '^\s\+let x = 1$', lines[40])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
179 call assert_match('^\s*1\s\+.*\selse$', lines[41])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
180 call assert_match('^\s*1\s\+.*\s let x = 2$', lines[42])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
181 call assert_match('^\s*1\s\+.*\sendif$', lines[43])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
182 call assert_equal('', lines[44])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
183 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
184 call assert_equal('count total (s) self (s) function', lines[46])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
185 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
186 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
187 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
188 call assert_equal('', lines[50])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
189 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
190 call assert_equal('count total (s) self (s) function', lines[52])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
191 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
192 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
193 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
194 call assert_equal('', lines[56])
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
195
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
196 call delete('Xprofile_func.vim')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
197 call delete('Xprofile_func.log')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
198 endfunc
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
199
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
200 func Test_profile_func_with_trycatch()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
201 let lines =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
202 func! Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
203 try
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
204 let x = 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
205 catch
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
206 let x = 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
207 finally
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
208 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
209 endtry
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
210 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
211 func! Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
212 try
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
213 throw 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
214 catch
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
215 let x = 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
216 finally
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
217 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
218 endtry
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
219 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
220 func! Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
221 try
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
222 throw 0
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
223 catch
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
224 throw 1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
225 finally
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
226 let x = 2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
227 endtry
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
228 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
229 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
230 call Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
231 try
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
232 call Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
233 catch
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
234 endtry
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
235 [CODE]
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
236
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
237 call writefile(lines, 'Xprofile_func.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
238 call system(GetVimCommand()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
239 \ . ' -es -i NONE --noplugin'
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
240 \ . ' -c "profile start Xprofile_func.log"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
241 \ . ' -c "profile func Foo*"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
242 \ . ' -c "so Xprofile_func.vim"'
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
243 \ . ' -c "qall!"')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
244 call assert_equal(0, v:shell_error)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
245
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
246 let lines = readfile('Xprofile_func.log')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
247
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
248 " - Foo1() should pass 'try' 'finally' blocks.
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
249 " - Foo2() should pass 'catch' 'finally' blocks.
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
250 " - Foo3() should not pass 'endtry'.
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
251 call assert_equal(57, len(lines))
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
252
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
253 call assert_equal('FUNCTION Foo1()', lines[0])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
254 call assert_match('Defined:.*Xprofile_func.vim', lines[1])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
255 call assert_equal('Called 1 time', lines[2])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
256 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
257 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
258 call assert_equal('', lines[5])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
259 call assert_equal('count total (s) self (s)', lines[6])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
260 call assert_match('^\s*1\s\+.*\stry$', lines[7])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
261 call assert_match('^\s*1\s\+.*\s let x = 0$', lines[8])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
262 call assert_match( '^\s\+catch$', lines[9])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
263 call assert_match( '^\s\+let x = 1$', lines[10])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
264 call assert_match('^\s*1\s\+.*\sfinally$', lines[11])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
265 call assert_match('^\s*1\s\+.*\s let x = 2$', lines[12])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
266 call assert_match('^\s*1\s\+.*\sendtry$', lines[13])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
267 call assert_equal('', lines[14])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
268 call assert_equal('FUNCTION Foo2()', lines[15])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
269 call assert_equal('Called 1 time', lines[17])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
270 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[18])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
271 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[19])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
272 call assert_equal('', lines[20])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
273 call assert_equal('count total (s) self (s)', lines[21])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
274 call assert_match('^\s*1\s\+.*\stry$', lines[22])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
275 call assert_match('^\s*1\s\+.*\s throw 0$', lines[23])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
276 call assert_match('^\s*1\s\+.*\scatch$', lines[24])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
277 call assert_match('^\s*1\s\+.*\s let x = 1$', lines[25])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
278 call assert_match('^\s*1\s\+.*\sfinally$', lines[26])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
279 call assert_match('^\s*1\s\+.*\s let x = 2$', lines[27])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
280 call assert_match('^\s*1\s\+.*\sendtry$', lines[28])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
281 call assert_equal('', lines[29])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
282 call assert_equal('FUNCTION Foo3()', lines[30])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
283 call assert_equal('Called 1 time', lines[32])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
284 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[33])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
285 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[34])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
286 call assert_equal('', lines[35])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
287 call assert_equal('count total (s) self (s)', lines[36])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
288 call assert_match('^\s*1\s\+.*\stry$', lines[37])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
289 call assert_match('^\s*1\s\+.*\s throw 0$', lines[38])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
290 call assert_match('^\s*1\s\+.*\scatch$', lines[39])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
291 call assert_match('^\s*1\s\+.*\s throw 1$', lines[40])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
292 call assert_match('^\s*1\s\+.*\sfinally$', lines[41])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
293 call assert_match('^\s*1\s\+.*\s let x = 2$', lines[42])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
294 call assert_match( '^\s\+endtry$', lines[43])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
295 call assert_equal('', lines[44])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
296 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
297 call assert_equal('count total (s) self (s) function', lines[46])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
298 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[47])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
299 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[48])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
300 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[49])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
301 call assert_equal('', lines[50])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
302 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
303 call assert_equal('count total (s) self (s) function', lines[52])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
304 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[53])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
305 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[54])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
306 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo.()$', lines[55])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
307 call assert_equal('', lines[56])
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
308
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
309 call delete('Xprofile_func.vim')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
310 call delete('Xprofile_func.log')
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
311 endfunc
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
312
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 func Test_profile_file()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
314 let lines =<< trim [CODE]
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
315 func! Foo()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
316 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
317 for i in range(10)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
318 " a comment
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
319 call Foo()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
320 endfor
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
321 call Foo()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
322 [CODE]
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 call writefile(lines, 'Xprofile_file.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
325 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
326 \ . ' -es'
10613
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
327 \ . ' -c "profile start Xprofile_file.log"'
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
328 \ . ' -c "profile file Xprofile_file.vim"'
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
329 \ . ' -c "so Xprofile_file.vim"'
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
330 \ . ' -c "so Xprofile_file.vim"'
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
331 \ . ' -c "qall!"')
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
332 call assert_equal(0, v:shell_error)
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 let lines = readfile('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 call assert_equal(14, len(lines))
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 call assert_equal('Sourced 2 times', lines[1])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 call assert_equal('', lines[4])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 call assert_equal('count total (s) self (s)', lines[5])
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
344 call assert_match(' 2 0.\d\+ func! Foo()', lines[6])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 call assert_equal(' endfunc', lines[7])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 " Loop iterates 10 times. Since script runs twice, body executes 20 times.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 " First line of loop executes one more time than body to detect end of loop.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+for i in range(10)$', lines[8])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 call assert_equal(' " a comment', lines[9])
12128
2f4eb2e10766 patch 8.0.0944: test_profile is a little bit flaky
Christian Brabandt <cb@256bit.org>
parents: 10613
diff changeset
350 " if self and total are equal we only get one number
2f4eb2e10766 patch 8.0.0944: test_profile is a little bit flaky
Christian Brabandt <cb@256bit.org>
parents: 10613
diff changeset
351 call assert_match('^\s*20\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[10])
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
352 call assert_match('^\s*22\s\+\d\+\.\d\+\s\+endfor$', lines[11])
10609
302aedeed8c9 patch 8.0.0194: profile tests fails if total and self time are equal
Christian Brabandt <cb@256bit.org>
parents: 10599
diff changeset
353 " if self and total are equal we only get one number
302aedeed8c9 patch 8.0.0194: profile tests fails if total and self time are equal
Christian Brabandt <cb@256bit.org>
parents: 10599
diff changeset
354 call assert_match('^\s*2\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[12])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 call assert_equal('', lines[13])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 call delete('Xprofile_file.vim')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 call delete('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
361 func Test_profile_file_with_cont()
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
362 let lines = [
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
363 \ 'echo "hello',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
364 \ ' \ world"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
365 \ 'echo "foo ',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
366 \ ' \bar"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
367 \ ]
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
368
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
369 call writefile(lines, 'Xprofile_file.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
370 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
371 \ . ' -es'
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
372 \ . ' -c "profile start Xprofile_file.log"'
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
373 \ . ' -c "profile file Xprofile_file.vim"'
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
374 \ . ' -c "so Xprofile_file.vim"'
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
375 \ . ' -c "qall!"')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
376 call assert_equal(0, v:shell_error)
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
377
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
378 let lines = readfile('Xprofile_file.log')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
379 call assert_equal(11, len(lines))
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
380
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
381 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
382 call assert_equal('Sourced 1 time', lines[1])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
383 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
384 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
385 call assert_equal('', lines[4])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
386 call assert_equal('count total (s) self (s)', lines[5])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
387 call assert_match(' 1 0.\d\+ echo "hello', lines[6])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
388 call assert_equal(' \ world"', lines[7])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
389 call assert_match(' 1 0.\d\+ echo "foo ', lines[8])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
390 call assert_equal(' \bar"', lines[9])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
391 call assert_equal('', lines[10])
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
392
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
393 call delete('Xprofile_file.vim')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
394 call delete('Xprofile_file.log')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
395 endfunc
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
396
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 func Test_profile_completion()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 call assert_equal('"profile continue file func pause start', @:)
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 call feedkeys(":profile start test_prof\<C-A>\<C-B>\"\<CR>", 'tx')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 call assert_match('^"profile start.* test_profile\.vim', @:)
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 func Test_profile_errors()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 call assert_fails("profile func Foo", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 call assert_fails("profile pause", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 call assert_fails("profile continue", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 endfunc
12992
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
410
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
411 func Test_profile_truncate_mbyte()
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14706
diff changeset
412 if &enc !=# 'utf-8'
12992
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
413 return
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
414 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
415
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
416 let lines = [
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
417 \ 'scriptencoding utf-8',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
418 \ 'func! Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
419 \ ' return [',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
420 \ ' \ "' . join(map(range(0x4E00, 0x4E00 + 340), 'nr2char(v:val)'), '') . '",',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
421 \ ' \ "' . join(map(range(0x4F00, 0x4F00 + 340), 'nr2char(v:val)'), '') . '",',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
422 \ ' \ ]',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
423 \ 'endfunc',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
424 \ 'call Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
425 \ ]
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
426
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
427 call writefile(lines, 'Xprofile_file.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
428 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
429 \ . ' -es --cmd "set enc=utf-8"'
12992
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
430 \ . ' -c "profile start Xprofile_file.log"'
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
431 \ . ' -c "profile file Xprofile_file.vim"'
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
432 \ . ' -c "so Xprofile_file.vim"'
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
433 \ . ' -c "qall!"')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
434 call assert_equal(0, v:shell_error)
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
435
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
436 split Xprofile_file.log
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
437 if &fenc != ''
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
438 call assert_equal('utf-8', &fenc)
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
439 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
440 /func! Foo()
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
441 let lnum = line('.')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
442 call assert_match('^\s*return \[$', getline(lnum + 1))
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
443 call assert_match("\u4F52$", getline(lnum + 2))
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
444 call assert_match("\u5052$", getline(lnum + 3))
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
445 call assert_match('^\s*\\ \]$', getline(lnum + 4))
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
446 bwipe!
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
447
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
448 call delete('Xprofile_file.vim')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
449 call delete('Xprofile_file.log')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
450 endfunc
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
451
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
452 func Test_profdel_func()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
453 let lines =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
454 profile start Xprofile_file.log
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
455 func! Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
456 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
457 func! Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
458 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
459 func! Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
460 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
461
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
462 profile func Foo1
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
463 profile func Foo2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
464 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
465 call Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
466
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
467 profile func Foo3
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
468 profdel func Foo2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
469 profdel func Foo3
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
470 call Foo1()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
471 call Foo2()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
472 call Foo3()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
473 [CODE]
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
474 call writefile(lines, 'Xprofile_file.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
475 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
476 call assert_equal(0, v:shell_error)
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
477
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
478 let lines = readfile('Xprofile_file.log')
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
479 call assert_equal(26, len(lines))
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
480
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
481 " Check that:
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
482 " - Foo1() is called twice (profdel not invoked)
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
483 " - Foo2() is called once (profdel invoked after it was called)
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
484 " - Foo3() is not called (profdel invoked before it was called)
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
485 call assert_equal('FUNCTION Foo1()', lines[0])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
486 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
487 call assert_equal('Called 2 times', lines[2])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
488 call assert_equal('FUNCTION Foo2()', lines[8])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
489 call assert_equal('Called 1 time', lines[10])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
490 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[16])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
491 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[21])
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
492
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
493 call delete('Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
494 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
495 endfunc
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
496
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
497 func Test_profdel_star()
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
498 " Foo() is invoked once before and once after 'profdel *'.
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
499 " So profiling should report it only once.
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
500 let lines =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
501 profile start Xprofile_file.log
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
502 func! Foo()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
503 endfunc
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
504 profile func Foo
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
505 call Foo()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
506 profdel *
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
507 call Foo()
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
508 [CODE]
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
509 call writefile(lines, 'Xprofile_file.vim')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
510 call system(GetVimCommandClean() . ' -es -c "so Xprofile_file.vim" -c q')
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
511 call assert_equal(0, v:shell_error)
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
512
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
513 let lines = readfile('Xprofile_file.log')
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
514 call assert_equal(16, len(lines))
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
515
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
516 call assert_equal('FUNCTION Foo()', lines[0])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
517 call assert_match('Defined:.*Xprofile_file.vim', lines[1])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
518 call assert_equal('Called 1 time', lines[2])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
519 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[8])
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
520 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[12])
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
521
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
522 call delete('Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
523 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
524 endfunc