Skip to content

Commit bbd13b1

Browse files
authored
feat(async): add timeout param to will_block (#285)
* feat(async): add timeout param to will_block * increase hardcoded timeout * fix(async): use vim.env.PLENARY_TEST_TIMEOUT for async test timeouts Better than hardcoding a random timeout. If we were to not provide a timeout here, it'd default to the async lib's internal default (2000).
1 parent 0a90736 commit bbd13b1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lua/plenary/async/tests.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ M.describe = function(s, async_func)
77
end
88

99
M.it = function(s, async_func)
10-
it(s, util.will_block(async_func))
10+
it(s, util.will_block(async_func, tonumber(vim.env.PLENARY_TEST_TIMEOUT)))
1111
end
1212

1313
M.before_each = function(async_func)

lua/plenary/async/util.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ M.block_on = function(async_function, timeout)
4040
return unpack(ret)
4141
end
4242

43-
M.will_block = function(async_func)
43+
---@see M.block_on
44+
---@param async_function Future
45+
---@param timeout number
46+
M.will_block = function(async_function, timeout)
4447
return function()
45-
M.block_on(async_func)
48+
M.block_on(async_function, timeout)
4649
end
4750
end
4851

lua/plenary/test_harness.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ function harness.test_directory(directory, opts)
4747
timeout = 50000,
4848
}, opts or {})
4949

50+
vim.env.PLENARY_TEST_TIMEOUT = opts.timeout
51+
5052
local res = {}
5153
if not headless then
5254
res = win_float.percentage_range_window(0.95, 0.70, opts.winopts)

0 commit comments

Comments
 (0)