comparison src/testdir/test_debugger.vim @ 22969:dcb59b1cc0c1 v8.2.2031

patch 8.2.2031: some tests fail when run under valgrind Commit: https://github.com/vim/vim/commit/18dc355395f2eac72ab83d984cacd26ae61c791f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 22 14:24:00 2020 +0100 patch 8.2.2031: some tests fail when run under valgrind Problem: Some tests fail when run under valgrind. Solution: Avoid timing problems.
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 Nov 2020 14:30:06 +0100
parents 4086a1708c83
children b545334ae654
comparison
equal deleted inserted replaced
22968:5ae81cb3da0a 22969:dcb59b1cc0c1
15 throw 'Skipped: Your CWD has too many characters' 15 throw 'Skipped: Your CWD has too many characters'
16 endif 16 endif
17 endfunc 17 endfunc
18 command! -nargs=0 -bar CheckCWD call CheckCWD() 18 command! -nargs=0 -bar CheckCWD call CheckCWD()
19 19
20 " "options" argument can contain:
21 " 'msec' - time to wait for a match
22 " 'match' - "pattern" to use "lines" as pattern instead of text
20 func CheckDbgOutput(buf, lines, options = {}) 23 func CheckDbgOutput(buf, lines, options = {})
21 " Verify the expected output 24 " Verify the expected output
22 let lnum = 20 - len(a:lines) 25 let lnum = 20 - len(a:lines)
26 let msec = get(a:options, 'msec', 1000)
23 for l in a:lines 27 for l in a:lines
24 if get(a:options, 'match', 'equal') ==# 'pattern' 28 if get(a:options, 'match', 'equal') ==# 'pattern'
25 call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, 200) 29 call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, msec)
26 else 30 else
27 call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, 200) 31 call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, msec)
28 endif 32 endif
29 let lnum += 1 33 let lnum += 1
30 endfor 34 endfor
31 endfunc 35 endfunc
32 36
196 200
197 " breakpoints tests 201 " breakpoints tests
198 202
199 " Start a debug session, so that reading the last line from the terminal 203 " Start a debug session, so that reading the last line from the terminal
200 " works properly. 204 " works properly.
201 call RunDbgCmd(buf, ':debug echo Foo()') 205 call RunDbgCmd(buf, ':debug echo Foo()', ['cmd: echo Foo()'])
202 206
203 " No breakpoints 207 " No breakpoints
204 call RunDbgCmd(buf, 'breakl', ['No breakpoints defined']) 208 call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
205 209
206 " Place some breakpoints 210 " Place some breakpoints
807 811
808 let buf = RunVimInTerminal( 812 let buf = RunVimInTerminal(
809 \ '-S Xtest1.vim -c "debug call GlobalFunction()"', 813 \ '-S Xtest1.vim -c "debug call GlobalFunction()"',
810 \ {'wait_for_ruler': 0}) 814 \ {'wait_for_ruler': 0})
811 815
812 " Need to wait for the vim-in-terminal to be ready 816 " Need to wait for the vim-in-terminal to be ready.
817 " With valgrind this can take quite long.
813 call CheckDbgOutput(buf, ['command line', 818 call CheckDbgOutput(buf, ['command line',
814 \ 'cmd: call GlobalFunction()']) 819 \ 'cmd: call GlobalFunction()'], #{msec: 5000})
815 820
816 " At this point the ontly thing in the stack is the cmdline 821 " At this point the ontly thing in the stack is the cmdline
817 call RunDbgCmd(buf, 'backtrace', [ 822 call RunDbgCmd(buf, 'backtrace', [
818 \ '>backtrace', 823 \ '>backtrace',
819 \ '->0 command line', 824 \ '->0 command line',
958 let file2 = getcwd() .. '/Xtest2.vim' 963 let file2 = getcwd() .. '/Xtest2.vim'
959 964
960 " set a breakpoint and source file1.vim 965 " set a breakpoint and source file1.vim
961 let buf = RunVimInTerminal( 966 let buf = RunVimInTerminal(
962 \ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim', 967 \ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim',
963 \ #{ wait_for_ruler: 0 } ) 968 \ #{wait_for_ruler: 0})
964 969
965 call CheckDbgOutput(buf, [ 970 call CheckDbgOutput(buf, [
966 \ 'Breakpoint in "' .. file1 .. '" line 1', 971 \ 'Breakpoint in "' .. file1 .. '" line 1',
967 \ 'Entering Debug mode. Type "cont" to continue.', 972 \ 'Entering Debug mode. Type "cont" to continue.',
968 \ 'command line..script ' .. file1, 973 \ 'command line..script ' .. file1,
969 \ 'line 1: let s:file1_var = ''file1''' 974 \ 'line 1: let s:file1_var = ''file1'''
970 \ ]) 975 \ ], #{msec: 5000})
971 976
972 " step throught the initial declarations 977 " step throught the initial declarations
973 call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] ) 978 call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] )
974 call RunDbgCmd(buf, 'step', [ 'line 4: func s:File1Func( arg )' ] ) 979 call RunDbgCmd(buf, 'step', [ 'line 4: func s:File1Func( arg )' ] )
975 call RunDbgCmd(buf, 'echo s:file1_var', [ 'file1' ] ) 980 call RunDbgCmd(buf, 'echo s:file1_var', [ 'file1' ] )