Mercurial > vim
comparison src/testdir/test_profile.vim @ 10613:196757b230a2 v8.0.0196
patch 8.0.0196: profile test is slo and does not work on MS-Windows
commit https://github.com/vim/vim/commit/c011a3d083001bcd9853b4447422f1819f3cee2f
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 16 22:37:42 2017 +0100
patch 8.0.0196: profile test is slo and does not work on MS-Windows
Problem: The test for :profile is slow and does not work on MS-Windows.
Solution: Use the "-es" argument. (Dominique Pelle) Swap single and double
quotes for system()
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 16 Jan 2017 22:45:04 +0100 |
parents | 302aedeed8c9 |
children | 2f4eb2e10766 |
comparison
equal
deleted
inserted
replaced
10612:2b6c101eb50e | 10613:196757b230a2 |
---|---|
2 if !has('profile') | 2 if !has('profile') |
3 finish | 3 finish |
4 endif | 4 endif |
5 | 5 |
6 func Test_profile_func() | 6 func Test_profile_func() |
7 if !has('unix') | |
8 return | |
9 endif | |
10 let lines = [ | 7 let lines = [ |
11 \ "func! Foo1()", | 8 \ "func! Foo1()", |
12 \ "endfunc", | 9 \ "endfunc", |
13 \ "func! Foo2()", | 10 \ "func! Foo2()", |
14 \ " let count = 100", | 11 \ " let l:count = 100", |
15 \ " while count > 0", | 12 \ " while l:count > 0", |
16 \ " let count = count - 1", | 13 \ " let l:count = l:count - 1", |
17 \ " endwhile", | 14 \ " endwhile", |
18 \ "endfunc", | 15 \ "endfunc", |
19 \ "func! Foo3()", | 16 \ "func! Foo3()", |
20 \ "endfunc", | 17 \ "endfunc", |
21 \ "func! Bar()", | 18 \ "func! Bar()", |
33 \ "endif", | 30 \ "endif", |
34 \ "delfunc Foo3", | 31 \ "delfunc Foo3", |
35 \ ] | 32 \ ] |
36 | 33 |
37 call writefile(lines, 'Xprofile_func.vim') | 34 call writefile(lines, 'Xprofile_func.vim') |
38 let a = system(v:progpath | 35 call system(v:progpath |
39 \ . " -u NONE -i NONE --noplugin" | 36 \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
40 \ . " -c 'profile start Xprofile_func.log'" | 37 \ . ' -c "profile start Xprofile_func.log"' |
41 \ . " -c 'profile func Foo*'" | 38 \ . ' -c "profile func Foo*"' |
42 \ . " -c 'so Xprofile_func.vim'" | 39 \ . ' -c "so Xprofile_func.vim"' |
43 \ . " -c 'qall!'") | 40 \ . ' -c "qall!"') |
41 call assert_equal(0, v:shell_error) | |
42 | |
44 let lines = readfile('Xprofile_func.log') | 43 let lines = readfile('Xprofile_func.log') |
45 | |
46 call assert_equal(28, len(lines)) | |
47 | |
48 call assert_equal('FUNCTION Foo1()', lines[0]) | |
49 call assert_equal('Called 2 times', lines[1]) | |
50 call assert_equal('FUNCTION Foo2()', lines[7]) | |
51 call assert_equal('Called 1 time', lines[8]) | |
52 | 44 |
53 " - Foo1() is called 3 times but should be reported as called twice | 45 " - Foo1() is called 3 times but should be reported as called twice |
54 " since one call is in between "profile pause" .. "profile continue". | 46 " since one call is in between "profile pause" .. "profile continue". |
55 " - Foo2() should come before Foo1() since Foo1() does much more work.\ | 47 " - Foo2() should come before Foo1() since Foo1() does much more work. |
56 " - Foo3() is not reported because function is deleted. | 48 " - Foo3() is not reported because function is deleted. |
57 " - Unlike Foo3(), Foo2() should not be deleted since there is a check | 49 " - Unlike Foo3(), Foo2() should not be deleted since there is a check |
58 " for v:profiling. | 50 " for v:profiling. |
59 " - Bar() is not reported since it does not match "profile func Foo*". | 51 " - Bar() is not reported since it does not match "profile func Foo*". |
60 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18]) | 52 call assert_equal(28, len(lines)) |
61 call assert_equal('count total (s) self (s) function', lines[19]) | 53 |
62 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20]) | 54 call assert_equal('FUNCTION Foo1()', lines[0]) |
63 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21]) | 55 call assert_equal('Called 2 times', lines[1]) |
64 call assert_equal('', lines[22]) | 56 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) |
65 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23]) | 57 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) |
66 call assert_equal('count total (s) self (s) function', lines[24]) | 58 call assert_equal('', lines[4]) |
67 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25]) | 59 call assert_equal('count total (s) self (s)', lines[5]) |
68 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26]) | 60 call assert_equal('', lines[6]) |
69 call assert_equal('', lines[27]) | 61 call assert_equal('FUNCTION Foo2()', lines[7]) |
62 call assert_equal('Called 1 time', lines[8]) | |
63 call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[9]) | |
64 call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[10]) | |
65 call assert_equal('', lines[11]) | |
66 call assert_equal('count total (s) self (s)', lines[12]) | |
67 call assert_match('^\s*1\s\+.*\slet l:count = 100$', lines[13]) | |
68 call assert_match('^\s*101\s\+.*\swhile l:count > 0$', lines[14]) | |
69 call assert_match('^\s*100\s\+.*\s let l:count = l:count - 1$', lines[15]) | |
70 call assert_match('^\s*100\s\+.*\sendwhile$', lines[16]) | |
71 call assert_equal('', lines[17]) | |
72 call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18]) | |
73 call assert_equal('count total (s) self (s) function', lines[19]) | |
74 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20]) | |
75 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21]) | |
76 call assert_equal('', lines[22]) | |
77 call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23]) | |
78 call assert_equal('count total (s) self (s) function', lines[24]) | |
79 call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25]) | |
80 call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26]) | |
81 call assert_equal('', lines[27]) | |
70 | 82 |
71 call delete('Xprofile_func.vim') | 83 call delete('Xprofile_func.vim') |
72 call delete('Xprofile_func.log') | 84 call delete('Xprofile_func.log') |
73 endfunc | 85 endfunc |
74 | 86 |
75 func Test_profile_file() | 87 func Test_profile_file() |
76 if !has('unix') | |
77 return | |
78 endif | |
79 let lines = [ | 88 let lines = [ |
80 \ 'func! Foo()', | 89 \ 'func! Foo()', |
81 \ 'endfunc', | 90 \ 'endfunc', |
82 \ 'for i in range(10)', | 91 \ 'for i in range(10)', |
83 \ ' " a comment', | 92 \ ' " a comment', |
85 \ 'endfor', | 94 \ 'endfor', |
86 \ 'call Foo()', | 95 \ 'call Foo()', |
87 \ ] | 96 \ ] |
88 | 97 |
89 call writefile(lines, 'Xprofile_file.vim') | 98 call writefile(lines, 'Xprofile_file.vim') |
90 let a = system(v:progpath | 99 call system(v:progpath |
91 \ . " -u NONE -i NONE --noplugin" | 100 \ . ' -es -u NONE -U NONE -i NONE --noplugin' |
92 \ . " -c 'profile start Xprofile_file.log'" | 101 \ . ' -c "profile start Xprofile_file.log"' |
93 \ . " -c 'profile file Xprofile_file.vim'" | 102 \ . ' -c "profile file Xprofile_file.vim"' |
94 \ . " -c 'so Xprofile_file.vim'" | 103 \ . ' -c "so Xprofile_file.vim"' |
95 \ . " -c 'so Xprofile_file.vim'" | 104 \ . ' -c "so Xprofile_file.vim"' |
96 \ . " -c 'qall!'") | 105 \ . ' -c "qall!"') |
106 call assert_equal(0, v:shell_error) | |
97 | 107 |
98 let lines = readfile('Xprofile_file.log') | 108 let lines = readfile('Xprofile_file.log') |
99 | 109 |
100 call assert_equal(14, len(lines)) | 110 call assert_equal(14, len(lines)) |
101 | 111 |