0
0
mirror of https://github.com/vim/vim.git synced 2025-07-24 10:45:12 -04:00

patch 8.0.1697: various tests are still a bit flaky

Problem:    Various tests are still a bit flaky.
Solution:   Increase the default wait time to five seconds.
This commit is contained in:
Bram Moolenaar 2018-04-11 20:53:49 +02:00
parent d60e0a1d20
commit 769e9d21ac
7 changed files with 15 additions and 13 deletions

View File

@ -60,8 +60,8 @@ func RunVimInTerminal(arguments, options)
call assert_equal([rows, cols], term_getsize(buf)) call assert_equal([rows, cols], term_getsize(buf))
" Wait for "All" of the ruler in the status line to be shown. " Wait for "All" of the ruler in the status line to be shown.
" This can be quite slow (e.g. when using valgrind), wait up to 4 seconds. " This can be quite slow (e.g. when using valgrind).
call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1}, 4000) call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1})
return buf return buf
endfunc endfunc
@ -70,7 +70,7 @@ endfunc
func StopVimInTerminal(buf) func StopVimInTerminal(buf)
call assert_equal("running", term_getstatus(a:buf)) call assert_equal("running", term_getstatus(a:buf))
call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>") call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>")
call WaitFor('term_getstatus(' . a:buf . ') == "finished"', 3000) call WaitFor('term_getstatus(' . a:buf . ') == "finished"')
only! only!
endfunc endfunc

View File

@ -113,14 +113,14 @@ func s:kill_server(cmd)
endif endif
endfunc endfunc
" Wait for up to a second for "expr" to become true. "expr" can be a " Wait for up to five seconds for "expr" to become true. "expr" can be a
" stringified expression to evaluate, or a funcref without arguments. " stringified expression to evaluate, or a funcref without arguments.
" A second argument can be used to specify a different timeout in msec. " A second argument can be used to specify a different timeout in msec.
" "
" Return time slept in milliseconds. With the +reltime feature this can be " Return time slept in milliseconds. With the +reltime feature this can be
" more than the actual waiting time. Without +reltime it can also be less. " more than the actual waiting time. Without +reltime it can also be less.
func WaitFor(expr, ...) func WaitFor(expr, ...)
let timeout = get(a:000, 0, 1000) let timeout = get(a:000, 0, 5000)
" using reltime() is more accurate, but not always available " using reltime() is more accurate, but not always available
if has('reltime') if has('reltime')
let start = reltime() let start = reltime()

View File

@ -1143,7 +1143,7 @@ func Test_pipe_to_buffer_raw()
let job = job_start([s:python, '-c', let job = job_start([s:python, '-c',
\ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options) \ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
call assert_equal("run", job_status(job)) call assert_equal("run", job_status(job))
call WaitFor('len(join(getline(1, "$"), "")) >= 10000', 3000) call WaitFor('len(join(getline(1, "$"), "")) >= 10000')
try try
let totlen = 0 let totlen = 0
for line in getline(1, '$') for line in getline(1, '$')
@ -1506,7 +1506,7 @@ func Test_exit_callback_interval()
let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0} let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0}
let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'}) let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'})
let g:exit_cb_val.process = job_info(job).process let g:exit_cb_val.process = job_info(job).process
call WaitFor('type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0', 2000) call WaitFor('type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0')
let elapsed = reltimefloat(g:exit_cb_val.end) let elapsed = reltimefloat(g:exit_cb_val.end)
call assert_true(elapsed > 0.5) call assert_true(elapsed > 0.5)
call assert_true(elapsed < 1.0) call assert_true(elapsed < 1.0)

View File

@ -32,7 +32,7 @@ func Test_client_server()
" Takes a short while for the server to be active. " Takes a short while for the server to be active.
" When using valgrind it takes much longer. " When using valgrind it takes much longer.
call WaitFor('serverlist() =~ "' . name . '"', 5000) call WaitFor('serverlist() =~ "' . name . '"')
call assert_match(name, serverlist()) call assert_match(name, serverlist())
call remote_foreground(name) call remote_foreground(name)

View File

@ -74,20 +74,20 @@ func Do_test_quotestar_for_x11()
" by the server. " by the server.
let @* = 'no' let @* = 'no'
call remote_foreground(name) call remote_foreground(name)
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "no"', 3000) call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "no"')
" Set the * register on the server. " Set the * register on the server.
call remote_send(name, ":let @* = 'yes'\<CR>") call remote_send(name, ":let @* = 'yes'\<CR>")
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"', 3000) call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"')
" Check that the *-register of this vim instance is changed as expected. " Check that the *-register of this vim instance is changed as expected.
call WaitFor('@* == "yes"', 3000) call WaitFor('@* == "yes"')
" Handle the large selection over 262040 byte. " Handle the large selection over 262040 byte.
let length = 262044 let length = 262044
let sample = 'a' . repeat('b', length - 2) . 'c' let sample = 'a' . repeat('b', length - 2) . 'c'
let @* = sample let @* = sample
call WaitFor('remote_expr("' . name . '", "len(@*) >= ' . length . '", "", 1)', 3000) call WaitFor('remote_expr("' . name . '", "len(@*) >= ' . length . '", "", 1)')
let res = remote_expr(name, "@*", "", 2) let res = remote_expr(name, "@*", "", 2)
call assert_equal(length, len(res)) call assert_equal(length, len(res))
" Check length to prevent a large amount of output at assertion failure. " Check length to prevent a large amount of output at assertion failure.

View File

@ -1061,7 +1061,7 @@ func Api_drop_common(options)
\ "set t_ts=", \ "set t_ts=",
\ ], 'Xscript') \ ], 'Xscript')
let buf = RunVimInTerminal('-S Xscript', {}) let buf = RunVimInTerminal('-S Xscript', {})
call WaitFor({-> bufnr('Xtextfile') > 0}, 5000) call WaitFor({-> bufnr('Xtextfile') > 0})
call assert_equal('Xtextfile', expand('%:t')) call assert_equal('Xtextfile', expand('%:t'))
call assert_true(winnr('$') >= 3) call assert_true(winnr('$') >= 3)
return buf return buf

View File

@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1697,
/**/ /**/
1696, 1696,
/**/ /**/