mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 09:12:07 +00:00
test/util: throttle retry() (#8296)
Avoid a hot loop in retry(), there's no need to retry more than 50/s. Also use luv.sleep() to implement sleep() instead of spinning the event-loop, so events are not silently discarded.
This commit is contained in:
@@ -309,6 +309,7 @@ local function retry(max, max_ms, fn)
|
||||
error("\nretry() attempts: "..tostring(tries).."\n"..tostring(result))
|
||||
end
|
||||
tries = tries + 1
|
||||
luv.sleep(20) -- Avoid hot loop...
|
||||
end
|
||||
end
|
||||
|
||||
@@ -467,14 +468,7 @@ end
|
||||
|
||||
-- sleeps the test runner (_not_ the nvim instance)
|
||||
local function sleep(ms)
|
||||
local function notification_cb(method, _)
|
||||
if method == "redraw" then
|
||||
error("Screen is attached; use screen:sleep() instead.")
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
run(nil, notification_cb, nil, ms)
|
||||
luv.sleep(ms)
|
||||
end
|
||||
|
||||
local function curbuf_contents()
|
||||
|
Reference in New Issue
Block a user