feat: lots of improvements to pipeline runner and converted all tasks to new system

This commit is contained in:
Folke Lemaitre 2022-11-28 22:03:44 +01:00
parent 4de10f9578
commit fb84c081b0
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
13 changed files with 381 additions and 200 deletions

View file

@ -19,33 +19,65 @@ describe("runner", function()
package.loaded["lazy.manage.task.test"]["test" .. i] = {
---@param task LazyTask
run = function(task)
table.insert(runs, { plugin = task.plugin.name, task = task.type })
table.insert(runs, { plugin = task.plugin.name, task = task.name })
end,
}
package.loaded["lazy.manage.task.test"]["error" .. i] = {
---@param task LazyTask
run = function(task)
table.insert(runs, { plugin = task.plugin.name, task = task.type })
table.insert(runs, { plugin = task.plugin.name, task = task.name })
error("error" .. i)
end,
}
package.loaded["lazy.manage.task.test"]["async" .. i] = {
---@param task LazyTask
run = function(task)
task:schedule(function()
table.insert(runs, { plugin = task.plugin.name, task = task.name })
end)
end,
}
end
it("runs the pipeline", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "test.test2" } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
it("waits", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "wait", "test.test2" } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
it("handles async", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.async1", "wait", "test.async2" } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
it("handles skips", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "test.skip", "test.test2" } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
it("handles opts", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", { "test.test2", foo = "bar" } } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
it("aborts on error", function()
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "test.error1", "test.test2" } })
runner:start()
runner:wait()
assert.equal(4, #runs)
end)
end)