mirror of https://github.com/folke/lazy.nvim.git
test: fix tests
This commit is contained in:
parent
6c7ef7e27a
commit
206d208018
|
@ -81,7 +81,7 @@ function Runner:_start()
|
|||
|
||||
---@param resume? boolean
|
||||
local function continue(resume)
|
||||
active = #names
|
||||
active = 0
|
||||
waiting = 0
|
||||
wait_step = nil
|
||||
for _, name in ipairs(names) do
|
||||
|
@ -90,19 +90,18 @@ function Runner:_start()
|
|||
local running = s.task and s.task:is_running()
|
||||
local step = self._pipeline[s.step]
|
||||
|
||||
if step and step.task == "wait" and not resume then
|
||||
if s.task and s.task:has_errors() then
|
||||
local ignore = true
|
||||
elseif step and step.task == "wait" and not resume then
|
||||
waiting = waiting + 1
|
||||
active = active - 1
|
||||
wait_step = s.step
|
||||
elseif not running then
|
||||
local plugin = self:plugin(name)
|
||||
if s.task and s.task:has_errors() then
|
||||
active = active - 1
|
||||
elseif s.step == #self._pipeline then
|
||||
if s.step == #self._pipeline then
|
||||
s.task = nil
|
||||
active = active - 1
|
||||
plugin._.working = false
|
||||
elseif s.step < #self._pipeline then
|
||||
active = active + 1
|
||||
s.step = s.step + 1
|
||||
step = self._pipeline[s.step]
|
||||
if step.task == "wait" then
|
||||
|
@ -112,6 +111,8 @@ function Runner:_start()
|
|||
plugin._.working = not not s.task
|
||||
end
|
||||
end
|
||||
else
|
||||
active = active + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -182,7 +182,7 @@ function Task:spawn(cmd, opts)
|
|||
local running = true
|
||||
---@param output string
|
||||
function opts.on_exit(ok, output)
|
||||
self:log(output, ok and vim.log.levels.DEBUG or vim.log.levels.ERROR)
|
||||
self:log(vim.trim(output), ok and vim.log.levels.DEBUG or vim.log.levels.ERROR)
|
||||
if on_exit then
|
||||
pcall(on_exit, ok, output)
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ describe("task", function()
|
|||
assert(not task:is_running())
|
||||
assert(task_result.done)
|
||||
assert(task_result.error)
|
||||
assert(task.error and task.error:find("test"))
|
||||
assert(task:has_errors() and task:output(vim.log.levels.ERROR):find("test"))
|
||||
end)
|
||||
|
||||
it("async", function()
|
||||
|
@ -56,7 +56,7 @@ describe("task", function()
|
|||
assert(not running)
|
||||
assert(not task:is_running())
|
||||
assert(task_result.done)
|
||||
assert(not task.error)
|
||||
assert(not task:has_errors())
|
||||
end)
|
||||
|
||||
it("spawn errors", function()
|
||||
|
@ -68,7 +68,7 @@ describe("task", function()
|
|||
task:wait()
|
||||
assert(not task:is_running())
|
||||
assert(task_result.done)
|
||||
assert(task.error and task.error:find("Failed to spawn"), task.output)
|
||||
assert(task:has_errors() and task:output(vim.log.levels.ERROR):find("Failed to spawn"), task.output)
|
||||
end)
|
||||
|
||||
it("spawn", function()
|
||||
|
@ -80,9 +80,9 @@ describe("task", function()
|
|||
assert(task:has_started())
|
||||
assert(task:is_running())
|
||||
task:wait()
|
||||
assert.same(task.output, "foo\n")
|
||||
assert.same(task:output(), "foo")
|
||||
assert(task_result.done)
|
||||
assert(not task.error)
|
||||
assert(not task:has_errors())
|
||||
end)
|
||||
|
||||
it("spawn 2x", function()
|
||||
|
@ -94,8 +94,8 @@ describe("task", function()
|
|||
assert(task:is_running())
|
||||
assert(task:is_running())
|
||||
task:wait()
|
||||
assert(task.output == "foo\nbar\n" or task.output == "bar\nfoo\n", task.output)
|
||||
assert(task:output() == "foo\nbar" or task:output() == "bar\nfoo", task:output())
|
||||
assert(task_result.done)
|
||||
assert(not task.error)
|
||||
assert(not task:has_errors())
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue