1
0
forked from aniani/vim

patch 7.4.2240

Problem:    Tests using the sleep time can be flaky.
Solution:   Use reltime() if available. (Partly by Shane Harper)
This commit is contained in:
Bram Moolenaar
2016-08-22 21:40:29 +02:00
parent 9baf297c99
commit f267f8bdf7
3 changed files with 37 additions and 7 deletions

View File

@@ -109,19 +109,31 @@ func s:kill_server(cmd)
endfunc
" Wait for up to a second for "expr" to become true.
" Return time slept in milliseconds.
" 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.
func WaitFor(expr)
let slept = 0
" using reltime() is more accurate, but not always available
if has('reltime')
let start = reltime()
else
let slept = 0
endif
for i in range(100)
try
if eval(a:expr)
if has('reltime')
return float2nr(reltimefloat(reltime(start)) * 1000)
endif
return slept
endif
catch
endtry
let slept += 10
if !has('reltime')
let slept += 10
endif
sleep 10m
endfor
return 1000
endfunc
" Run Vim, using the "vimcmd" file and "-u NORC".