Skip to content

Commit 18dc355

Browse files
committed
patch 8.2.2031: some tests fail when run under valgrind
Problem: Some tests fail when run under valgrind. Solution: Avoid timing problems.
1 parent 4b2ce12 commit 18dc355

6 files changed

Lines changed: 30 additions & 18 deletions

File tree

src/testdir/test_channel.vim

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,18 +2181,21 @@ func Test_issue_5150()
21812181
else
21822182
let cmd = 'grep foo'
21832183
endif
2184+
21842185
let g:job = job_start(cmd, {})
2186+
sleep 50m " give the job time to start
21852187
call job_stop(g:job)
2186-
sleep 50m
2187-
call assert_equal(-1, job_info(g:job).exitval)
2188+
call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
2189+
21882190
let g:job = job_start(cmd, {})
2189-
call job_stop(g:job, 'term')
21902191
sleep 50m
2191-
call assert_equal(-1, job_info(g:job).exitval)
2192+
call job_stop(g:job, 'term')
2193+
call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
2194+
21922195
let g:job = job_start(cmd, {})
2193-
call job_stop(g:job, 'kill')
21942196
sleep 50m
2195-
call assert_equal(-1, job_info(g:job).exitval)
2197+
call job_stop(g:job, 'kill')
2198+
call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
21962199
endfunc
21972200

21982201
func Test_issue_5485()

src/testdir/test_clientserver.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ func Test_client_server()
6363
call remote_send(name, ":gui -f\<CR>")
6464
endif
6565
" Wait for the server to be up and answering requests.
66-
sleep 100m
67-
call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")})
66+
" When using valgrind this can be very, very slow.
67+
sleep 1
68+
call WaitForAssert({-> assert_match('\d', name->remote_expr("v:version", "", 1))}, 10000)
6869

6970
call remote_send(name, ":let testvar = 'maybe'\<CR>")
7071
call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})

src/testdir/test_debugger.vim

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ func CheckCWD()
1717
endfunc
1818
command! -nargs=0 -bar CheckCWD call CheckCWD()
1919

20+
" "options" argument can contain:
21+
" 'msec' - time to wait for a match
22+
" 'match' - "pattern" to use "lines" as pattern instead of text
2023
func CheckDbgOutput(buf, lines, options = {})
2124
" Verify the expected output
2225
let lnum = 20 - len(a:lines)
26+
let msec = get(a:options, 'msec', 1000)
2327
for l in a:lines
2428
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)
2630
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)
2832
endif
2933
let lnum += 1
3034
endfor
@@ -198,7 +202,7 @@ func Test_Debugger()
198202

199203
" Start a debug session, so that reading the last line from the terminal
200204
" works properly.
201-
call RunDbgCmd(buf, ':debug echo Foo()')
205+
call RunDbgCmd(buf, ':debug echo Foo()', ['cmd: echo Foo()'])
202206

203207
" No breakpoints
204208
call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
@@ -809,9 +813,10 @@ func Test_Backtrace_CmdLine()
809813
\ '-S Xtest1.vim -c "debug call GlobalFunction()"',
810814
\ {'wait_for_ruler': 0})
811815

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.
813818
call CheckDbgOutput(buf, ['command line',
814-
\ 'cmd: call GlobalFunction()'])
819+
\ 'cmd: call GlobalFunction()'], #{msec: 5000})
815820

816821
" At this point the ontly thing in the stack is the cmdline
817822
call RunDbgCmd(buf, 'backtrace', [
@@ -960,14 +965,14 @@ func Test_debug_backtrace_level()
960965
" set a breakpoint and source file1.vim
961966
let buf = RunVimInTerminal(
962967
\ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim',
963-
\ #{ wait_for_ruler: 0 } )
968+
\ #{wait_for_ruler: 0})
964969

965970
call CheckDbgOutput(buf, [
966971
\ 'Breakpoint in "' .. file1 .. '" line 1',
967972
\ 'Entering Debug mode. Type "cont" to continue.',
968973
\ 'command line..script ' .. file1,
969974
\ 'line 1: let s:file1_var = ''file1'''
970-
\ ])
975+
\ ], #{msec: 5000})
971976

972977
" step throught the initial declarations
973978
call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] )

src/testdir/test_quotestar.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ func Do_test_quotestar_for_x11()
9898

9999
" Running in a terminal and the GUI is available: Tell the server to open
100100
" the GUI and check that the remote command still works.
101-
" Need to wait for the GUI to start up, otherwise the send hangs in trying
102-
" to send to the terminal window.
103101
if has('gui_athena') || has('gui_motif')
104102
" For those GUIs, ignore the 'failed to create input context' error.
105103
call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
106104
else
107105
call remote_send(name, ":gui -f\<CR>")
108106
endif
109107
" Wait for the server in the GUI to be up and answering requests.
108+
" First need to wait for the GUI to start up, otherwise the send hangs in
109+
" trying to send to the terminal window.
110110
" On some systems and with valgrind this can be very slow.
111+
sleep 1
111112
call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))}, 10000)
112113

113114
call remote_send(name, ":let @* = 'maybe'\<CR>")

src/testdir/test_vim9_func.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def TestCompilingError()
3737
for i in range(1, 9)
3838
text ..= term_getline(buf, i)
3939
endfor
40-
if text =~ 'Error detected'
40+
if text =~ 'Variable not found: nothing'
4141
break
4242
endif
4343
sleep 20m

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2031,
753755
/**/
754756
2030,
755757
/**/

0 commit comments

Comments
 (0)