fix(async): make asyncs abortable

This commit is contained in:
Folke Lemaitre 2024-06-30 13:35:11 +02:00
parent c882227f1f
commit 1fad61712b
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
7 changed files with 29 additions and 8 deletions

View file

@ -1,3 +1,4 @@
local Async = require("lazy.async")
local Runner = require("lazy.manage.runner")
describe("runner", function()
@ -33,7 +34,7 @@ describe("runner", function()
---@async
---@param task LazyTask
run = function(task)
coroutine.yield()
Async.yield()
table.insert(runs, { plugin = task.plugin.name, task = task.name })
end,
}

View file

@ -1,4 +1,5 @@
--# selene:allow(incorrect_standard_library_use)
local Async = require("lazy.async")
local Task = require("lazy.manage.task")
describe("task", function()
@ -42,7 +43,7 @@ describe("task", function()
local running = true
---@async
local task = Task.new(plugin, "test", function()
coroutine.yield()
Async.yield()
running = false
end, opts)
assert(task:running())