aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-28 23:48:20 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-28 23:53:28 -0400
commit489d3b084f2a4c90f49258ddf5b7c9fb5ed8607a (patch)
tree689e2ae58af4f6a0d65d7e1828a48ee7e9347693 /src
parentbddc4dc0ed56d8714be340c5f95bea12ceb00255 (diff)
downloadrneovim-489d3b084f2a4c90f49258ddf5b7c9fb5ed8607a.tar.gz
rneovim-489d3b084f2a4c90f49258ddf5b7c9fb5ed8607a.tar.bz2
rneovim-489d3b084f2a4c90f49258ddf5b7c9fb5ed8607a.zip
vim-patch:8.0.1259: search test can be flaky
Problem: Search test can be flaky. Solution: Use WaitFor() instead of a delay. Make it possible to pass a funcref to WaitFor() to avoid the need for global variables. (James McCoy, closes vim/vim#2282) https://github.com/vim/vim/commit/13deab8d08145c1f6e2a3e82cb547bc7f87a3686
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/shared.vim11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index a5cf4def4f..6cc2d06a36 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -133,7 +133,9 @@ func s:kill_server(cmd)
endif
endfunc
-" Wait for up to a second for "expr" to become true.
+" Wait for up to a second for "expr" to become true. "expr" can be a
+" stringified expression to evaluate, or a funcref without arguments.
+"
" 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
@@ -146,8 +148,13 @@ func WaitFor(expr, ...)
else
let slept = 0
endif
+ if type(a:expr) == v:t_func
+ let Test = a:expr
+ else
+ let Test = {-> eval(a:expr) }
+ endif
for i in range(timeout / 10)
- if eval(a:expr)
+ if Test()
if has('reltime')
return float2nr(reltimefloat(reltime(start)) * 1000)
endif