diff options
| author | Jurica Bradaric <jbradaric@gmail.com> | 2017-03-20 20:52:54 +0100 |
|---|---|---|
| committer | Jurica Bradaric <jbradaric@gmail.com> | 2017-03-20 21:15:56 +0100 |
| commit | 5c2f1e29e3dfdfab8c2a9b31962d9cc12c171e46 (patch) | |
| tree | 506e168dff9c7b414cec0b3a089ea100adec03fc /src/nvim/testdir/shared.vim | |
| parent | 420a9955fa969ee0460f41798c60c1374476fd08 (diff) | |
| download | rneovim-5c2f1e29e3dfdfab8c2a9b31962d9cc12c171e46.tar.gz rneovim-5c2f1e29e3dfdfab8c2a9b31962d9cc12c171e46.tar.bz2 rneovim-5c2f1e29e3dfdfab8c2a9b31962d9cc12c171e46.zip | |
vim-patch:7.4.2240
Problem: Tests using the sleep time can be flaky.
Solution: Use reltime() if available. (Partly by Shane Harper)
https://github.com/vim/vim/commit/f267f8bdf777073e392ada5b31d837c7b6090eb4
Diffstat (limited to 'src/nvim/testdir/shared.vim')
| -rw-r--r-- | src/nvim/testdir/shared.vim | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim index 9573f5a9c3..1138ceba4d 100644 --- a/src/nvim/testdir/shared.vim +++ b/src/nvim/testdir/shared.vim @@ -1,17 +1,28 @@ " Functions shared by several tests. -" 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) - return slept + 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 |