annotate src/testdir/test_profile.vim @ 35075:43739470fe40 default tip

runtime(asm): missing setlocal in indent plugin (#14658) Commit: https://github.com/vim/vim/commit/2e9b9e9a9ebf3fd40437260ecd6b1e23b02c636b Author: Marc Sven Schulte <167623652+msschulte@users.noreply.github.com> Date: Sun Apr 28 21:43:03 2024 +0200 runtime(asm): missing setlocal in indent plugin (https://github.com/vim/vim/issues/14658) Signed-off-by: Marc Sven Schulte <167623652+msschulte@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 28 Apr 2024 21:45:03 +0200
parents 98774a275d6d
children
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
17899
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
7 source screendump.vim
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
8
32160
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
9 if has('prof_nsec')
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
10 let s:header = 'count total (s) self (s)'
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
11 let s:header_func = 'count total (s) self (s) function'
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
12 else
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
13 let s:header = 'count total (s) self (s)'
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
14 let s:header_func = 'count total (s) self (s) function'
98774a275d6d patch 9.0.1411: accuracy of profiling is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 32134
diff changeset
15 endif
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
16
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 func Test_profile_func()
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
18 call RunProfileFunc('func', 'let', 'let')
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
19 call RunProfileFunc('def', 'var', '')
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
20 endfunc
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
21
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
22 func RunProfileFunc(command, declare, assign)
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
23 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
24 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
25 profile func Foo*
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
26 XXX Foo1()
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
27 endXXX
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
28 XXX Foo2()
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
29 DDD counter = 100
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
30 while counter > 0
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
31 AAA counter = counter - 1
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
32 endwhile
19683
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
33 sleep 1m
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
34 endXXX
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
35 XXX Foo3()
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
36 endXXX
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
37 XXX Bar()
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
38 endXXX
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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 [CODE]
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
53 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
54 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
55 call map(lines, {k, v -> substitute(v, 'AAA', a:assign, '') })
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
56
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
57 call writefile(lines, 'Xprofile_func.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
58 call system(GetVimCommand()
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
59 \ . ' -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
60 \ . ' -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
61 \ . ' -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
62 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
63
30158
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 28373
diff changeset
64 sleep 50m
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 let lines = readfile('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 " - 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
68 " 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
69 " - 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
70 " - 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
71 " - 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
72 " for v:profiling.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 " - Bar() is not reported since it does not match "profile func Foo*".
19683
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
74 call assert_equal(31, 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
75
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
76 call assert_equal('FUNCTION Foo1()', lines[0])
18120
ed222e264905 patch 8.1.2055: not easy to jump to function line from profile
Bram Moolenaar <Bram@vim.org>
parents: 17899
diff changeset
77 call assert_match('Defined:.*Xprofile_func.vim:3', lines[1])
14706
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_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
79 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
80 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
81 call assert_equal('', lines[5])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
82 call assert_equal(s:header, lines[6])
14706
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_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
84 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
85 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
86 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
87 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
88 call assert_equal('', lines[13])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
89 call assert_equal(s:header, lines[14])
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
90 call assert_match('^\s*1\s\+.*\s\(let\|var\) counter = 100$', lines[15])
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
91 call assert_match('^\s*101\s\+.*\swhile counter > 0$', lines[16])
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
92 call assert_match('^\s*100\s\+.*\s \(let\)\= counter = counter - 1$', lines[17])
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
93 call assert_match('^\s*10[01]\s\+.*\sendwhile$', lines[18])
19683
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
94 call assert_match('^\s*1\s\+.\+sleep 1m$', lines[19])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
95 call assert_equal('', lines[20])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
96 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[21])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
97 call assert_equal(s:header_func, lines[22])
19683
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
98 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[23])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
99 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[24])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
100 call assert_equal('', lines[25])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
101 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[26])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
102 call assert_equal(s:header_func, lines[27])
19683
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
103 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[28])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
104 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[29])
dd028abdde0f patch 8.2.0398: profile test fails when two functions take same time
Bram Moolenaar <Bram@vim.org>
parents: 18120
diff changeset
105 call assert_equal('', lines[30])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 call delete('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
110 func Test_profile_func_with_ifelse()
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
111 call Run_profile_func_with_ifelse('func', 'let')
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
112 call Run_profile_func_with_ifelse('def', 'var')
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
113 endfunc
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
114
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
115 func Run_profile_func_with_ifelse(command, declare)
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
116 let lines =<< trim [CODE]
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
117 XXX Foo1()
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
118 if 1
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
119 DDD x = 0
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
120 elseif 1
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
121 DDD x = 1
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
122 else
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
123 DDD x = 2
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
124 endif
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
125 endXXX
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
126 XXX Foo2()
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
127 if 0
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
128 DDD x = 0
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
129 elseif 1
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
130 DDD x = 1
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
131 else
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
132 DDD x = 2
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
133 endif
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
134 endXXX
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
135 XXX Foo3()
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
136 if 0
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
137 DDD x = 0
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
138 elseif 0
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
139 DDD x = 1
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
140 else
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
141 DDD x = 2
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
142 endif
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
143 endXXX
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
144 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
145 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
146 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
147 [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
148
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
149 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
150 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
151
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
152 call writefile(lines, 'Xprofile_func.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
153 call system(GetVimCommand()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
154 \ . ' -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
155 \ . ' -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
156 \ . ' -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
157 \ . ' -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
158 \ . ' -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
159 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
160
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
161 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
162
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
163 " - 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
164 " - 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
165 " - 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
166 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
167
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
168 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
169 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
170 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
171 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
172 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
173 call assert_equal('', lines[5])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
174 call assert_equal(s:header, lines[6])
14706
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 1$', lines[7])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
176 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
14706
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\+elseif 1$', lines[9])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
178 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
14706
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\+else$', lines[11])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
180 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[12])
14706
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[13])
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[14])
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('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
184 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
185 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
186 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
187 call assert_equal('', lines[20])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
188 call assert_equal(s:header, lines[21])
14706
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_match('^\s*1\s\+.*\sif 0$', lines[22])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
190 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[23])
14706
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\+.*\selseif 1$', lines[24])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
192 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
14706
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\+else$', lines[26])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
194 call assert_match( '^\s\+\(let\|var\) x = 2$', lines[27])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
195 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
196 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
197 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
198 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
199 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
200 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
201 call assert_equal('', lines[35])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
202 call assert_equal(s:header, lines[36])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
203 call assert_match('^\s*1\s\+.*\sif 0$', lines[37])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
204 call assert_match( '^\s\+\(let\|var\) x = 0$', lines[38])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
205 call assert_match('^\s*1\s\+.*\selseif 0$', lines[39])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
206 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[40])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
207 call assert_match('^\s*1\s\+.*\selse$', lines[41])
23723
14e92f4c98c9 patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
208 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
209 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
210 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
211 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
212 call assert_equal(s:header_func, lines[46])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
213 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
214 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
215 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
216 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
217 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
218 call assert_equal(s:header_func, lines[52])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
219 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
220 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
221 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
222 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
223
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
224 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
225 endfunc
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
226
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
227 func Test_profile_func_with_trycatch()
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
228 call Run_profile_func_with_trycatch('func', 'let')
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
229 call Run_profile_func_with_trycatch('def', 'var')
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
230 endfunc
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
231
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
232 func Run_profile_func_with_trycatch(command, declare)
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
233 let lines =<< trim [CODE]
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
234 XXX Foo1()
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
235 try
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
236 DDD x = 0
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
237 catch
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
238 DDD x = 1
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
239 finally
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
240 DDD x = 2
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
241 endtry
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
242 endXXX
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
243 XXX Foo2()
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
244 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
245 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
246 catch
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
247 DDD x = 1
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
248 finally
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
249 DDD x = 2
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
250 endtry
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
251 endXXX
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
252 XXX Foo3()
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
253 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
254 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
255 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
256 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
257 finally
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
258 DDD x = 2
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
259 endtry
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
260 endXXX
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
261 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
262 call Foo2()
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
263 let rethrown = 0
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
264 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
265 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
266 catch
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
267 let rethrown = 1
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
268 endtry
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
269 if rethrown != 1
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
270 " call Foo1 again so that the test fails
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
271 call Foo1()
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
272 endif
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
273 [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
274
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
275 call map(lines, {k, v -> substitute(v, 'XXX', a:command, '') })
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
276 call map(lines, {k, v -> substitute(v, 'DDD', a:declare, '') })
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
277
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
278 call writefile(lines, 'Xprofile_func.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
279 call system(GetVimCommand()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
280 \ . ' -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
281 \ . ' -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
282 \ . ' -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
283 \ . ' -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
284 \ . ' -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
285 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
286
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
287 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
288
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
289 " - 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
290 " - 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
291 " - 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
292 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
293
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
294 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
295 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
296 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
297 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
298 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
299 call assert_equal('', lines[5])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
300 call assert_equal(s:header, lines[6])
14706
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_match('^\s*1\s\+.*\stry$', lines[7])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
302 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 0$', lines[8])
14706
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_match( '^\s\+catch$', lines[9])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
304 call assert_match( '^\s\+\(let\|var\) x = 1$', lines[10])
14706
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\+.*\sfinally$', lines[11])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
306 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[12])
14706
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_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
308 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
309 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
310 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
311 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
312 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
313 call assert_equal('', lines[20])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
314 call assert_equal(s:header, lines[21])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
315 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
316 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
317 call assert_match('^\s*1\s\+.*\scatch$', lines[24])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
318 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 1$', lines[25])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
319 call assert_match('^\s*1\s\+.*\sfinally$', lines[26])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
320 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[27])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
321 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
322 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
323 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
324 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
325 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
326 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
327 call assert_equal('', lines[35])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
328 call assert_equal(s:header, lines[36])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
329 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
330 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
331 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
332 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
333 call assert_match('^\s*1\s\+.*\sfinally$', lines[41])
23725
f98692ae09a0 patch 8.2.2404: Vim9: profiling try/catch not correct
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
334 call assert_match('^\s*1\s\+.*\s \(let\|var\) x = 2$', lines[42])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
335 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
336 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
337 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[45])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
338 call assert_equal(s:header_func, lines[46])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
339 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
340 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
341 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
342 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
343 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[51])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
344 call assert_equal(s:header_func, lines[52])
14706
2c0f454fcdc9 patch 8.1.0365: function profile doesn't specify where it was defined
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
345 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
346 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
347 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
348 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
349
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
350 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
351 endfunc
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14228
diff changeset
352
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 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
354 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
355 func! Foo()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
356 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
357 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
358 " a comment
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
359 call Foo()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
360 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
361 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
362 [CODE]
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
364 call writefile(lines, 'Xprofile_file.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
365 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
366 \ . ' -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
367 \ . ' -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
368 \ . ' -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
369 \ . ' -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
370 \ . ' -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
371 \ . ' -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
372 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
373
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 let lines = readfile('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 call assert_equal(14, len(lines))
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 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
379 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
380 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
381 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
382 call assert_equal('', lines[4])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
383 call assert_equal(s:header, 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
384 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
385 call assert_equal(' endfunc', lines[7])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 " 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
387 " 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
388 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
389 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
390 " 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
391 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
392 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
393 " 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
394 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
395 call assert_equal('', lines[13])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 call delete('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
400 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
401 let lines = [
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
402 \ 'echo "hello',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
403 \ ' \ world"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
404 \ 'echo "foo ',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
405 \ ' \bar"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
406 \ ]
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
407
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
408 call writefile(lines, 'Xprofile_file.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
409 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
410 \ . ' -es'
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
411 \ . ' -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
412 \ . ' -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
413 \ . ' -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
414 \ . ' -c "qall!"')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
415 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
416
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
417 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
418 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
419
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
420 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
421 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
422 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
423 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
424 call assert_equal('', lines[4])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
425 call assert_equal(s:header, lines[5])
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
426 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
427 call assert_equal(' \ world"', lines[7])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
428 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
429 call assert_equal(' \bar"', lines[9])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
430 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
431
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
432 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
433 endfunc
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
434
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
435 " Test for ':profile stop' and ':profile dump' commands
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
436 func Test_profile_stop_dump()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
437 call delete('Xprof1.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
438 call delete('Xprof2.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
439 call delete('Xprof3.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
440 func Xprof_test1()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
441 return "Hello"
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
442 endfunc
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
443 func Xprof_test2()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
444 return "World"
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
445 endfunc
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
446
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
447 " Test for ':profile stop'
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
448 profile start Xprof1.out
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
449 profile func Xprof_test1
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
450 call Xprof_test1()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
451 profile stop
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
452
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
453 let lines = readfile('Xprof1.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
454 call assert_equal(17, len(lines))
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
455 call assert_equal('FUNCTION Xprof_test1()', lines[0])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
456 call assert_match('Defined:.*test_profile.vim:', lines[1])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
457 call assert_equal('Called 1 time', lines[2])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
458 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
459 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
460 call assert_equal('', lines[5])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
461 call assert_equal(s:header, lines[6])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
462 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
463 call assert_equal('', lines[8])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
464 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
465 call assert_equal(s:header_func, lines[10])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
466 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
467 call assert_equal('', lines[12])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
468 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
469 call assert_equal(s:header_func, lines[14])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
470 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
471 call assert_equal('', lines[16])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
472
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
473 " Test for ':profile stop' for a different function
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
474 profile start Xprof2.out
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
475 profile func Xprof_test2
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
476 call Xprof_test2()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
477 profile stop
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
478 let lines = readfile('Xprof2.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
479 call assert_equal(17, len(lines))
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
480 call assert_equal('FUNCTION Xprof_test2()', lines[0])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
481 call assert_match('Defined:.*test_profile.vim:', lines[1])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
482 call assert_equal('Called 1 time', lines[2])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
483 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[3])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
484 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[4])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
485 call assert_equal('', lines[5])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
486 call assert_equal(s:header, lines[6])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
487 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[7])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
488 call assert_equal('', lines[8])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
489 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[9])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
490 call assert_equal(s:header_func, lines[10])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
491 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[11])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
492 call assert_equal('', lines[12])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
493 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[13])
32134
c8612da7564c patch 9.0.1398: profile test repeats the headers many times
Bram Moolenaar <Bram@vim.org>
parents: 30592
diff changeset
494 call assert_equal(s:header_func, lines[14])
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
495 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test2()$', lines[15])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
496 call assert_equal('', lines[16])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
497
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
498 " Test for ':profile dump'
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
499 profile start Xprof3.out
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
500 profile func Xprof_test1
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
501 profile func Xprof_test2
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
502 call Xprof_test1()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
503 profile dump
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
504 " dump the profile once and verify the contents
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
505 let lines = readfile('Xprof3.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
506 call assert_equal(17, len(lines))
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
507 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
508 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[11])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
509 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Xprof_test1()$', lines[15])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
510 " dump the profile again and verify the contents
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
511 call Xprof_test2()
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
512 profile dump
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
513 profile stop
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
514 let lines = readfile('Xprof3.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
515 call assert_equal(28, len(lines))
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
516 call assert_equal('FUNCTION Xprof_test1()', lines[0])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
517 call assert_match('^\s*1\s\+.*\sreturn "Hello"$', lines[7])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
518 call assert_equal('FUNCTION Xprof_test2()', lines[9])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
519 call assert_match('^\s*1\s\+.*\sreturn "World"$', lines[16])
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
520
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
521 delfunc Xprof_test1
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
522 delfunc Xprof_test2
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
523 call delete('Xprof1.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
524 call delete('Xprof2.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
525 call delete('Xprof3.out')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
526 endfunc
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
527
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
528 " Test for :profile sub-command completion
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 func Test_profile_completion()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
531 call assert_equal('"profile continue dump file func pause start stop', @:)
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 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
534 call assert_match('^"profile start.* test_profile\.vim', @:)
28091
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
535
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
536 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
537 call assert_match('"profile file test_profile\.vim', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
538 call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
539 call assert_match('"profile file test_profile\.vim', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
540 call feedkeys(":profile file test_prof \<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
541 call assert_match('"profile file test_prof ', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
542 call feedkeys(":profile file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
543 call assert_match('"profile file X1B2C3', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
544
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
545 func Xprof_test()
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
546 endfunc
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
547 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
548 call assert_equal('"profile func Xprof_test', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
549 call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
550 call assert_equal('"profile func Xprof_test', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
551 call feedkeys(":profile func Xprof \<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
552 call assert_equal('"profile func Xprof ', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
553 call feedkeys(":profile func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
554 call assert_equal('"profile func X1B2C3', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
555
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
556 call feedkeys(":profdel \<C-A>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
557 call assert_equal('"profdel file func', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
558 call feedkeys(":profdel fu\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
559 call assert_equal('"profdel func', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
560 call feedkeys(":profdel he\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
561 call assert_equal('"profdel he', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
562 call feedkeys(":profdel here \<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
563 call assert_equal('"profdel here ', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
564 call feedkeys(":profdel file test_prof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
565 call assert_equal('"profdel file test_profile.vim', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
566 call feedkeys(":profdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
567 call assert_equal('"profdel file X1B2C3', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
568 call feedkeys(":profdel func Xprof\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
569 call assert_equal('"profdel func Xprof_test', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
570 call feedkeys(":profdel func Xprof_test \<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
571 call assert_equal('"profdel func Xprof_test ', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
572 call feedkeys(":profdel func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx')
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
573 call assert_equal('"profdel func X1B2C3', @:)
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
574
554f493902ea patch 8.2.4570: no command line completion for :profile and :profdel
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
575 delfunc Xprof_test
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 func Test_profile_errors()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 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
580 call assert_fails("profile pause", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 call assert_fails("profile continue", 'E750:')
28373
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
582 call assert_fails("profile stop", 'E750:')
2ddf8aa1252c patch 8.2.4712: only get profiling information after exiting
Bram Moolenaar <Bram@vim.org>
parents: 28091
diff changeset
583 call assert_fails("profile dump", 'E750:')
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 endfunc
12992
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
585
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
586 func Test_profile_truncate_mbyte()
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14706
diff changeset
587 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
588 return
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
589 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
590
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
591 let lines = [
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
592 \ '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
593 \ 'func! Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
594 \ ' return [',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
595 \ ' \ "' . 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
596 \ ' \ "' . 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
597 \ ' \ ]',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
598 \ 'endfunc',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
599 \ 'call Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
600 \ ]
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
601
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
602 call writefile(lines, 'Xprofile_file.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
603 call system(GetVimCommandClean()
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
604 \ . ' -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
605 \ . ' -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
606 \ . ' -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
607 \ . ' -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
608 \ . ' -c "qall!"')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
609 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
610
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
611 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
612 if &fenc != ''
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
613 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
614 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
615 /func! Foo()
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
616 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
617 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
618 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
619 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
620 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
621 bwipe!
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
622
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
623 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
624 endfunc
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
625
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
626 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
627 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
628 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
629 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
630 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
631 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
632 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
633 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
634 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
635
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
636 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
637 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
638 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
639 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
640
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
641 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
642 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
643 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
644 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
645 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
646 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
647 [CODE]
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
648 call writefile(lines, 'Xprofile_file.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
649 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
650 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
651
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
652 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
653 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
654
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
655 " Check that:
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
656 " - 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
657 " - 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
658 " - 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
659 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
660 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
661 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
662 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
663 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
664 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
665 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
666
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
667 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
668 endfunc
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
669
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
670 func Test_profdel_star()
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
671 " 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
672 " 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
673 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
674 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
675 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
676 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
677 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
678 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
679 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
680 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
681 [CODE]
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
682 call writefile(lines, 'Xprofile_file.vim', 'D')
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
683 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
684 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
685
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
686 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
687 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
688
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
689 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
690 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
691 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
692 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
693 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
694
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
695 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
696 endfunc
17899
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
697
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
698 " When typing the function it won't have a script ID, test that this works.
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
699 func Test_profile_typed_func()
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
700 CheckScreendump
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
701
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
702 let lines =<< trim END
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
703 profile start XprofileTypedFunc
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
704 END
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
705 call writefile(lines, 'XtestProfile', 'D')
17899
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
706 let buf = RunVimInTerminal('-S XtestProfile', #{})
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
707
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
708 call term_sendkeys(buf, ":func DoSomething()\<CR>"
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
709 \ .. "echo 'hello'\<CR>"
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
710 \ .. "endfunc\<CR>")
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
711 call term_sendkeys(buf, ":profile func DoSomething\<CR>")
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
712 call term_sendkeys(buf, ":call DoSomething()\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19683
diff changeset
713 call TermWait(buf, 100)
17899
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
714 call StopVimInTerminal(buf)
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
715 let lines = readfile('XprofileTypedFunc')
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
716 call assert_equal("FUNCTION DoSomething()", lines[0])
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
717 call assert_equal("Called 1 time", lines[1])
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
718
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
719 " clean up
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
720 call delete('XprofileTypedFunc')
48fd0712dad8 patch 8.1.1946: memory error when profiling a function without a script ID
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
721 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
722
23735
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
723 func Test_vim9_profiling()
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
724 " only tests that compiling and calling functions doesn't crash
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
725 let lines =<< trim END
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
726 vim9script
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
727 def Func()
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
728 Crash()
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
729 enddef
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
730 def Crash()
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
731 enddef
23740
9b55c60f9d52 patch 8.2.2411: profile test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 23735
diff changeset
732 prof start Xprofile_crash.log
23735
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
733 prof func Func
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
734 Func()
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
735 END
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
736 call writefile(lines, 'Xprofile_crash.vim', 'D')
23740
9b55c60f9d52 patch 8.2.2411: profile test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 23735
diff changeset
737 call system(GetVimCommandClean() . ' -es -c "so Xprofile_crash.vim" -c q')
9b55c60f9d52 patch 8.2.2411: profile test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 23735
diff changeset
738 call assert_equal(0, v:shell_error)
24059
24887299c5ff patch 8.2.2571: test may leave file behind
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
739 call assert_true(readfile('Xprofile_crash.log')->len() > 10)
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
740
23740
9b55c60f9d52 patch 8.2.2411: profile test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 23735
diff changeset
741 call delete('Xprofile_crash.log')
23735
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
742 endfunc
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
743
23976
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
744 func Test_vim9_nested_call()
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
745 let lines =<< trim END
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
746 vim9script
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
747 var total = 0
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
748 def One(Ref: func(number))
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
749 for i in range(3)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
750 Ref(i)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
751 endfor
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
752 enddef
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
753 def Two(nr: number)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
754 total += nr
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
755 enddef
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
756 prof start Xprofile_nested.log
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
757 prof func One
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
758 prof func Two
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
759 One((nr) => Two(nr))
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
760 assert_equal(3, total)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
761 END
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
762 call writefile(lines, 'Xprofile_nested.vim', 'D')
23976
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
763 call system(GetVimCommandClean() . ' -es -c "so Xprofile_nested.vim" -c q')
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
764 call assert_equal(0, v:shell_error)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
765
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
766 let prof_lines = readfile('Xprofile_nested.log')->join('#')
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
767 call assert_match('FUNCTION <SNR>\d\+_One().*'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
768 \ .. '#Called 1 time.*'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
769 \ .. '# 1 \s*[0-9.]\+ for i in range(3)'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
770 \ .. '# 3 \s*[0-9.]\+ \s*[0-9.]\+ Ref(i)'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
771 \ .. '# 3 \s*[0-9.]\+ endfor', prof_lines)
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
772 call assert_match('FUNCTION <SNR>\d\+_Two().*'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
773 \ .. '#Called 3 times.*'
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
774 \ .. '# 3 \s*[0-9.]\+ total += nr', prof_lines)
30592
457ea0570b6f patch 9.0.0631: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
775
24043
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23976
diff changeset
776 call delete('Xprofile_nested.log')
23976
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
777 endfunc
03819ebd3e6d patch 8.2.2530: Vim9: not enough testing for profiling
Bram Moolenaar <Bram@vim.org>
parents: 23740
diff changeset
778
23735
7caffd835aa1 patch 8.2.2409: Vim9: profiling only works for one function
Bram Moolenaar <Bram@vim.org>
parents: 23725
diff changeset
779
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
780 " vim: shiftwidth=2 sts=2 expandtab