vim-patch:8.2.2031: some tests fail when run under valgrind

Problem:    Some tests fail when run under valgrind.
Solution:   Avoid timing problems.
18dc355395
This commit is contained in:
zeertzjq
2022-08-22 09:48:11 +08:00
parent af2b078258
commit b94cfaf080
3 changed files with 18 additions and 11 deletions

View File

@@ -66,8 +66,9 @@ func Test_client_server()
call remote_send(name, ":gui -f\<CR>") call remote_send(name, ":gui -f\<CR>")
endif endif
" Wait for the server to be up and answering requests. " Wait for the server to be up and answering requests.
sleep 100m " When using valgrind this can be very, very slow.
call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")}) sleep 1
call WaitForAssert({-> assert_match('\d', name->remote_expr("v:version", "", 1))}, 10000)
call remote_send(name, ":let testvar = 'maybe'\<CR>") call remote_send(name, ":let testvar = 'maybe'\<CR>")
call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))}) call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})

View File

@@ -15,14 +15,18 @@ func CheckCWD()
endfunc endfunc
command! -nargs=0 -bar CheckCWD call CheckCWD() command! -nargs=0 -bar CheckCWD call CheckCWD()
" "options" argument can contain:
" 'msec' - time to wait for a match
" 'match' - "pattern" to use "lines" as pattern instead of text
func CheckDbgOutput(buf, lines, options = {}) func CheckDbgOutput(buf, lines, options = {})
" Verify the expected output " Verify the expected output
let lnum = 20 - len(a:lines) let lnum = 20 - len(a:lines)
let msec = get(a:options, 'msec', 1000)
for l in a:lines for l in a:lines
if get(a:options, 'match', 'equal') ==# 'pattern' if get(a:options, 'match', 'equal') ==# 'pattern'
call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, 200) call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, msec)
else else
call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, 200) call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, msec)
endif endif
let lnum += 1 let lnum += 1
endfor endfor
@@ -198,7 +202,7 @@ func Test_Debugger()
" Start a debug session, so that reading the last line from the terminal " Start a debug session, so that reading the last line from the terminal
" works properly. " works properly.
call RunDbgCmd(buf, ':debug echo Foo()') call RunDbgCmd(buf, ':debug echo Foo()', ['cmd: echo Foo()'])
" No breakpoints " No breakpoints
call RunDbgCmd(buf, 'breakl', ['No breakpoints defined']) call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
@@ -814,9 +818,10 @@ func Test_Backtrace_CmdLine()
\ '-S Xtest1.vim -c "debug call GlobalFunction()"', \ '-S Xtest1.vim -c "debug call GlobalFunction()"',
\ {'wait_for_ruler': 0}) \ {'wait_for_ruler': 0})
" Need to wait for the vim-in-terminal to be ready " Need to wait for the vim-in-terminal to be ready.
" With valgrind this can take quite long.
call CheckDbgOutput(buf, ['command line', call CheckDbgOutput(buf, ['command line',
\ 'cmd: call GlobalFunction()']) \ 'cmd: call GlobalFunction()'], #{msec: 5000})
" At this point the ontly thing in the stack is the cmdline " At this point the ontly thing in the stack is the cmdline
call RunDbgCmd(buf, 'backtrace', [ call RunDbgCmd(buf, 'backtrace', [
@@ -967,14 +972,14 @@ func Test_debug_backtrace_level()
" set a breakpoint and source file1.vim " set a breakpoint and source file1.vim
let buf = RunVimInTerminal( let buf = RunVimInTerminal(
\ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim', \ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim',
\ #{ wait_for_ruler: 0 } ) \ #{wait_for_ruler: 0})
call CheckDbgOutput(buf, [ call CheckDbgOutput(buf, [
\ 'Breakpoint in "' .. file1 .. '" line 1', \ 'Breakpoint in "' .. file1 .. '" line 1',
\ 'Entering Debug mode. Type "cont" to continue.', \ 'Entering Debug mode. Type "cont" to continue.',
\ 'command line..script ' .. file1, \ 'command line..script ' .. file1,
\ 'line 1: let s:file1_var = ''file1''' \ 'line 1: let s:file1_var = ''file1'''
\ ]) \ ], #{msec: 5000})
" step through the initial declarations " step through the initial declarations
call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] ) call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] )

View File

@@ -98,8 +98,6 @@ func Do_test_quotestar_for_x11()
" Running in a terminal and the GUI is available: Tell the server to open " Running in a terminal and the GUI is available: Tell the server to open
" the GUI and check that the remote command still works. " the GUI and check that the remote command still works.
" Need to wait for the GUI to start up, otherwise the send hangs in trying
" to send to the terminal window.
if has('gui_athena') || has('gui_motif') if has('gui_athena') || has('gui_motif')
" For those GUIs, ignore the 'failed to create input context' error. " For those GUIs, ignore the 'failed to create input context' error.
call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>") call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
@@ -107,7 +105,10 @@ func Do_test_quotestar_for_x11()
call remote_send(name, ":gui -f\<CR>") call remote_send(name, ":gui -f\<CR>")
endif endif
" Wait for the server in the GUI to be up and answering requests. " Wait for the server in the GUI to be up and answering requests.
" First need to wait for the GUI to start up, otherwise the send hangs in
" trying to send to the terminal window.
" On some systems and with valgrind this can be very slow. " On some systems and with valgrind this can be very slow.
sleep 1
call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))}, 10000) call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))}, 10000)
call remote_send(name, ":let @* = 'maybe'\<CR>") call remote_send(name, ":let @* = 'maybe'\<CR>")