diff src/testdir/test_profile.vim @ 12658:20aacdca367d v8.0.1207

patch 8.0.1207: profiling skips the first and last script line commit https://github.com/vim/vim/commit/67435d9983965c5c77fc74f0559779ce4554dacb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 19 21:04:37 2017 +0200 patch 8.0.1207: profiling skips the first and last script line Problem: Profiling skips the first and last script line. Solution: Check for BOM after setting script ID. (Lemonboy, closes https://github.com/vim/vim/issues/2103, closes #2112) Add a test. List the trailing script lines.
author Christian Brabandt <cb@256bit.org>
date Thu, 19 Oct 2017 21:15:04 +0200
parents 2f4eb2e10766
children 5532b5176870
line wrap: on
line diff
--- a/src/testdir/test_profile.vim
+++ b/src/testdir/test_profile.vim
@@ -115,7 +115,7 @@ func Test_profile_file()
   call assert_match('^ Self time:\s\+\d\+\.\d\+$',                    lines[3])
   call assert_equal('',                                               lines[4])
   call assert_equal('count  total (s)   self (s)',                    lines[5])
-  call assert_equal('                            func! Foo()',        lines[6])
+  call assert_match('    2              0.\d\+ func! Foo()',          lines[6])
   call assert_equal('                            endfunc',            lines[7])
   " Loop iterates 10 times. Since script runs twice, body executes 20 times.
   " First line of loop executes one more time than body to detect end of loop.
@@ -132,6 +132,42 @@ func Test_profile_file()
   call delete('Xprofile_file.log')
 endfunc
 
+func Test_profile_file_with_cont()
+  let lines = [
+    \ 'echo "hello',
+    \ '  \ world"',
+    \ 'echo "foo ',
+    \ '  \bar"',
+    \ ]
+
+  call writefile(lines, 'Xprofile_file.vim')
+  call system(v:progpath
+    \ . ' -es --clean'
+    \ . ' -c "profile start Xprofile_file.log"'
+    \ . ' -c "profile file Xprofile_file.vim"'
+    \ . ' -c "so Xprofile_file.vim"'
+    \ . ' -c "qall!"')
+  call assert_equal(0, v:shell_error)
+
+  let lines = readfile('Xprofile_file.log')
+  call assert_equal(11, len(lines))
+
+  call assert_match('^SCRIPT .*Xprofile_file.vim$',                   lines[0])
+  call assert_equal('Sourced 1 time',                                lines[1])
+  call assert_match('^Total time:\s\+\d\+\.\d\+$',                    lines[2])
+  call assert_match('^ Self time:\s\+\d\+\.\d\+$',                    lines[3])
+  call assert_equal('',                                               lines[4])
+  call assert_equal('count  total (s)   self (s)',                    lines[5])
+  call assert_match('    1              0.\d\+ echo "hello',          lines[6])
+  call assert_equal('                              \ world"',         lines[7])
+  call assert_match('    1              0.\d\+ echo "foo ',           lines[8])
+  call assert_equal('                              \bar"',            lines[9])
+  call assert_equal('',                                               lines[10])
+
+  call delete('Xprofile_file.vim')
+  call delete('Xprofile_file.log')
+endfunc
+
 func Test_profile_completion()
   call feedkeys(":profile \<C-A>\<C-B>\"\<CR>", 'tx')
   call assert_equal('"profile continue file func pause start', @:)