aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-01-17 23:24:03 +0100
committerGitHub <noreply@github.com>2019-01-17 23:24:03 +0100
commit8093cbd8e8ca06ce5c9d8814fc6d94cb2304133a (patch)
tree0a803cb317580bdb27533bd9550440e3ebcd84ff /test/functional/helpers.lua
parenta8a38f346548f507f06ff07d790d87913007523f (diff)
parent06785da5b611d750314caf152a5acdaa60ddf1b7 (diff)
downloadrneovim-8093cbd8e8ca06ce5c9d8814fc6d94cb2304133a.tar.gz
rneovim-8093cbd8e8ca06ce5c9d8814fc6d94cb2304133a.tar.bz2
rneovim-8093cbd8e8ca06ce5c9d8814fc6d94cb2304133a.zip
Merge #9292 from mhinz/xcode10
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index ec5c83fa92..3e72ba6f98 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -678,6 +678,44 @@ local function alter_slashes(obj)
end
end
+local function compute_load_factor()
+ local timeout = 200
+ local times = {}
+
+ clear()
+
+ for _ = 1, 5 do
+ source([[
+ let g:val = 0
+ call timer_start(200, {-> nvim_set_var('val', 1)})
+ let start = reltime()
+ while 1
+ sleep 10m
+ if g:val == 1
+ let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000)
+ break
+ endif
+ endwhile
+ ]])
+ table.insert(times, nvim_eval('g:waited_in_ms'))
+ end
+
+ session:close()
+ session = nil
+
+ local longest = math.max(unpack(times))
+ local factor = (longest + 50.0) / timeout
+
+ return factor
+end
+
+-- Compute load factor only once.
+local load_factor = compute_load_factor()
+
+local function load_adjust(num)
+ return math.ceil(num * load_factor)
+end
+
local module = {
NIL = mpack.NIL,
alter_slashes = alter_slashes,
@@ -719,6 +757,7 @@ local module = {
meths = meths,
missing_provider = missing_provider,
mkdir = lfs.mkdir,
+ load_adjust = load_adjust,
near = near,
neq = neq,
new_pipename = new_pipename,