annotate src/testdir/test_profile.vim @ 14228:24109c2e0b0b v8.1.0131

patch 8.1.0131: :profdel is not tested commit https://github.com/vim/vim/commit/1fbfe7c48cb711f5a6deae535b3ec3bfe7952ce9 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 30 21:18:13 2018 +0200 patch 8.1.0131: :profdel is not tested Problem: :profdel is not tested. Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/3123)
author Christian Brabandt <cb@256bit.org>
date Sat, 30 Jun 2018 21:30:06 +0200
parents 5532b5176870
children 96878f6f5d4c
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
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 if !has('profile')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 finish
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 endif
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func Test_profile_func()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 let lines = [
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
8 \ 'profile start Xprofile_func.log',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
9 \ 'profile func Foo*"',
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 \ "func! Foo1()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 \ "endfunc",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 \ "func! Foo2()",
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
13 \ " let l:count = 100",
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
14 \ " while l:count > 0",
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
15 \ " let l:count = l:count - 1",
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 \ " endwhile",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 \ "endfunc",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 \ "func! Foo3()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 \ "endfunc",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 \ "func! Bar()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 \ "endfunc",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 \ "call Foo1()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 \ "call Foo1()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 \ "profile pause",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 \ "call Foo1()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 \ "profile continue",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 \ "call Foo2()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 \ "call Foo3()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 \ "call Bar()",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 \ "if !v:profiling",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 \ " delfunc Foo2",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 \ "endif",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 \ "delfunc Foo3",
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 \ ]
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call writefile(lines, 'Xprofile_func.vim')
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
37 call system(v:progpath
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
38 \ . ' -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
39 \ . ' -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
40 \ . ' -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
41 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
42
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 let lines = readfile('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " - 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
46 " 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
47 " - 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
48 " - 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
49 " - 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
50 " for v:profiling.
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " - Bar() is not reported since it does not match "profile func Foo*".
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
52 call assert_equal(28, len(lines))
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
53
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
54 call assert_equal('FUNCTION Foo1()', lines[0])
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
55 call assert_equal('Called 2 times', lines[1])
196757b230a2 patch 8.0.0196: profile test is slo and does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10609
diff changeset
56 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2])
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
57 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3])
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
58 call assert_equal('', lines[4])
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
59 call assert_equal('count total (s) self (s)', lines[5])
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 call assert_equal('', lines[6])
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 call assert_equal('FUNCTION Foo2()', lines[7])
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('Called 1 time', lines[8])
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 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[9])
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
64 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[10])
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
65 call assert_equal('', lines[11])
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
66 call assert_equal('count total (s) self (s)', lines[12])
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
67 call assert_match('^\s*1\s\+.*\slet l:count = 100$', lines[13])
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
68 call assert_match('^\s*101\s\+.*\swhile l:count > 0$', lines[14])
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 call assert_match('^\s*100\s\+.*\s let l:count = l:count - 1$', lines[15])
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
70 call assert_match('^\s*100\s\+.*\sendwhile$', lines[16])
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
71 call assert_equal('', lines[17])
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
72 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18])
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
73 call assert_equal('count total (s) self (s) function', lines[19])
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
74 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20])
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 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21])
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('', lines[22])
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
77 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23])
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
78 call assert_equal('count total (s) self (s) function', lines[24])
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
79 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25])
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
80 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26])
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
81 call assert_equal('', lines[27])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 call delete('Xprofile_func.vim')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 call delete('Xprofile_func.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 func Test_profile_file()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 let lines = [
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 \ 'func! Foo()',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 \ 'endfunc',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 \ 'for i in range(10)',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 \ ' " a comment',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 \ ' call Foo()',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 \ 'endfor',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 \ 'call Foo()',
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 \ ]
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 call writefile(lines, 'Xprofile_file.vim')
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
99 call system(v:progpath
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
100 \ . ' -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
101 \ . ' -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
102 \ . ' -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
103 \ . ' -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
104 \ . ' -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
105 \ . ' -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
106 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
107
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 let lines = readfile('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 call assert_equal(14, len(lines))
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 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
113 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
114 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
115 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
116 call assert_equal('', lines[4])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 call assert_equal('count total (s) self (s)', lines[5])
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
118 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
119 call assert_equal(' endfunc', lines[7])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 " 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
121 " 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
122 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
123 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
124 " 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
125 call assert_match('^\s*20\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[10])
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 call assert_match('^\s*20\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
127 " 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
128 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
129 call assert_equal('', lines[13])
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 call delete('Xprofile_file.vim')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 call delete('Xprofile_file.log')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
12658
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
135 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
136 let lines = [
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
137 \ 'echo "hello',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
138 \ ' \ world"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
139 \ 'echo "foo ',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
140 \ ' \bar"',
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
141 \ ]
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
142
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
143 call writefile(lines, '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
144 call system(v:progpath
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
145 \ . ' -es --clean'
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
146 \ . ' -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
147 \ . ' -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
148 \ . ' -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
149 \ . ' -c "qall!"')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
150 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
151
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
152 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
153 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
154
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
155 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
156 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
157 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
158 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
159 call assert_equal('', lines[4])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
160 call assert_equal('count total (s) self (s)', lines[5])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
161 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
162 call assert_equal(' \ world"', lines[7])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
163 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
164 call assert_equal(' \bar"', lines[9])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
165 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
166
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
167 call delete('Xprofile_file.vim')
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
168 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
169 endfunc
20aacdca367d patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents: 12128
diff changeset
170
10599
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 func Test_profile_completion()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 call assert_equal('"profile continue file func pause start', @:)
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 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
176 call assert_match('^"profile start.* test_profile\.vim', @:)
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 endfunc
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 func Test_profile_errors()
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 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
181 call assert_fails("profile pause", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 call assert_fails("profile continue", 'E750:')
2748b23db6bb patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 endfunc
12992
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
184
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
185 func Test_profile_truncate_mbyte()
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
186 if !has('multi_byte') || &enc !=# 'utf-8'
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
187 return
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
188 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
189
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
190 let lines = [
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
191 \ '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
192 \ 'func! Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
193 \ ' return [',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
194 \ ' \ "' . 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
195 \ ' \ "' . 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
196 \ ' \ ]',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
197 \ 'endfunc',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
198 \ 'call Foo()',
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
199 \ ]
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
200
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
201 call writefile(lines, '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
202 call system(v:progpath
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
203 \ . ' -es --clean --cmd "set enc=utf-8"'
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
204 \ . ' -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
205 \ . ' -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
206 \ . ' -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
207 \ . ' -c "qall!"')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
208 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
209
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
210 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
211 if &fenc != ''
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
212 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
213 endif
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
214 /func! Foo()
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
215 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
216 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
217 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
218 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
219 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
220 bwipe!
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
221
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
222 call delete('Xprofile_file.vim')
5532b5176870 patch 8.0.1372: profile log may be truncated halfway a character
Christian Brabandt <cb@256bit.org>
parents: 12658
diff changeset
223 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
224 endfunc
14228
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
225
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
226 func Test_profdel_func()
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
227 let lines = [
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
228 \ 'profile start Xprofile_file.log',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
229 \ 'func! Foo1()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
230 \ 'endfunc',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
231 \ 'func! Foo2()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
232 \ 'endfunc',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
233 \ 'func! Foo3()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
234 \ 'endfunc',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
235 \ '',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
236 \ 'profile func Foo1',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
237 \ 'profile func Foo2',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
238 \ 'call Foo1()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
239 \ 'call Foo2()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
240 \ '',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
241 \ 'profile func Foo3',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
242 \ 'profdel func Foo2',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
243 \ 'profdel func Foo3',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
244 \ 'call Foo1()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
245 \ 'call Foo2()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
246 \ 'call Foo3()' ]
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
247 call writefile(lines, 'Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
248 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
249 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
250
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
251 let lines = readfile('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
252 call assert_equal(24, len(lines))
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
253
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
254 " Check that:
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
255 " - 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
256 " - 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
257 " - 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
258 call assert_equal('FUNCTION Foo1()', lines[0])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
259 call assert_equal('Called 2 times', lines[1])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
260 call assert_equal('FUNCTION Foo2()', lines[7])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
261 call assert_equal('Called 1 time', lines[8])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
262 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[14])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
263 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[19])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
264
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
265 call delete('Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
266 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
267 endfunc
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
268
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
269 func Test_profdel_star()
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
270 " 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
271 " So profiling should report it only once.
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
272 let lines = [
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
273 \ 'profile start Xprofile_file.log',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
274 \ 'func! Foo()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
275 \ 'endfunc',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
276 \ 'profile func Foo',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
277 \ 'call Foo()',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
278 \ 'profdel *',
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
279 \ 'call Foo()' ]
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
280 call writefile(lines, 'Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
281 call system(v:progpath . ' -es --clean -c "so Xprofile_file.vim" -c q')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
282 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
283
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
284 let lines = readfile('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
285 call assert_equal(15, len(lines))
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
286
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
287 call assert_equal('FUNCTION Foo()', lines[0])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
288 call assert_equal('Called 1 time', lines[1])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
289 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[7])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
290 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[11])
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
291
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
292 call delete('Xprofile_file.vim')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
293 call delete('Xprofile_file.log')
24109c2e0b0b patch 8.1.0131: :profdel is not tested
Christian Brabandt <cb@256bit.org>
parents: 12992
diff changeset
294 endfunc