Mercurial > vim
annotate src/testdir/test_profile.vim @ 13860:7f892e37b017 v8.0.1801
patch 8.0.1801: MS-Windows: redirecting terminal output does not work
commit https://github.com/vim/vim/commit/f25329cb94e481999e8b08d886cc0f0169e2020c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 6 21:49:32 2018 +0200
patch 8.0.1801: MS-Windows: redirecting terminal output does not work
Problem: MS-Windows: redirecting terminal output does not work.
Solution: Intercept the text written to the terminal and write it to the
file.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 May 2018 22:00:07 +0200 |
parents | 5532b5176870 |
children | 24109c2e0b0b |
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 = [ |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 \ "func! Foo1()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 \ "endfunc", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 \ "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
|
11 \ " 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
|
12 \ " 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
|
13 \ " 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
|
14 \ " endwhile", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 \ "endfunc", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 \ "func! Foo3()", |
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! Bar()", |
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 \ "call Foo1()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 \ "call Foo1()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 \ "profile pause", |
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 continue", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 \ "call Foo2()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 \ "call Foo3()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 \ "call Bar()", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 \ "if !v:profiling", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 \ " delfunc Foo2", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 \ "endif", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 \ "delfunc Foo3", |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ ] |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
2748b23db6bb
patch 8.0.0189: profile commands are not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 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
|
35 call system(v:progpath |
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
|
36 \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
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 \ . ' -c "profile start Xprofile_func.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
|
38 \ . ' -c "profile func Foo*"' |
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 |
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
|
100 \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
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 |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
155 call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
156 call assert_equal('Sourced 1 time', lines[1]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
157 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
158 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
159 call assert_equal('', lines[4]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
160 call assert_equal('count total (s) self (s)', lines[5]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
161 call assert_match(' 1 0.\d\+ echo "hello', lines[6]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
162 call assert_equal(' \ world"', lines[7]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
163 call assert_match(' 1 0.\d\+ echo "foo ', lines[8]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
164 call assert_equal(' \bar"', lines[9]) |
20aacdca367d
patch 8.0.1207: profiling skips the first and last script line
Christian Brabandt <cb@256bit.org>
parents:
12128
diff
changeset
|
165 call assert_equal('', lines[10]) |
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 |