Skip to content

Commit 206d208

Browse files
committed
test: fix tests
1 parent 6c7ef7e commit 206d208

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

lua/lazy/manage/runner.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function Runner:_start()
8181

8282
---@param resume? boolean
8383
local function continue(resume)
84-
active = #names
84+
active = 0
8585
waiting = 0
8686
wait_step = nil
8787
for _, name in ipairs(names) do
@@ -90,19 +90,18 @@ function Runner:_start()
9090
local running = s.task and s.task:is_running()
9191
local step = self._pipeline[s.step]
9292

93-
if step and step.task == "wait" and not resume then
93+
if s.task and s.task:has_errors() then
94+
local ignore = true
95+
elseif step and step.task == "wait" and not resume then
9496
waiting = waiting + 1
95-
active = active - 1
9697
wait_step = s.step
9798
elseif not running then
9899
local plugin = self:plugin(name)
99-
if s.task and s.task:has_errors() then
100-
active = active - 1
101-
elseif s.step == #self._pipeline then
100+
if s.step == #self._pipeline then
102101
s.task = nil
103-
active = active - 1
104102
plugin._.working = false
105103
elseif s.step < #self._pipeline then
104+
active = active + 1
106105
s.step = s.step + 1
107106
step = self._pipeline[s.step]
108107
if step.task == "wait" then
@@ -112,6 +111,8 @@ function Runner:_start()
112111
plugin._.working = not not s.task
113112
end
114113
end
114+
else
115+
active = active + 1
115116
end
116117
end
117118
end

lua/lazy/manage/task/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function Task:spawn(cmd, opts)
182182
local running = true
183183
---@param output string
184184
function opts.on_exit(ok, output)
185-
self:log(output, ok and vim.log.levels.DEBUG or vim.log.levels.ERROR)
185+
self:log(vim.trim(output), ok and vim.log.levels.DEBUG or vim.log.levels.ERROR)
186186
if on_exit then
187187
pcall(on_exit, ok, output)
188188
end

tests/manage/task_spec.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("task", function()
3838
assert(not task:is_running())
3939
assert(task_result.done)
4040
assert(task_result.error)
41-
assert(task.error and task.error:find("test"))
41+
assert(task:has_errors() and task:output(vim.log.levels.ERROR):find("test"))
4242
end)
4343

4444
it("async", function()
@@ -56,7 +56,7 @@ describe("task", function()
5656
assert(not running)
5757
assert(not task:is_running())
5858
assert(task_result.done)
59-
assert(not task.error)
59+
assert(not task:has_errors())
6060
end)
6161

6262
it("spawn errors", function()
@@ -68,7 +68,7 @@ describe("task", function()
6868
task:wait()
6969
assert(not task:is_running())
7070
assert(task_result.done)
71-
assert(task.error and task.error:find("Failed to spawn"), task.output)
71+
assert(task:has_errors() and task:output(vim.log.levels.ERROR):find("Failed to spawn"), task.output)
7272
end)
7373

7474
it("spawn", function()
@@ -80,9 +80,9 @@ describe("task", function()
8080
assert(task:has_started())
8181
assert(task:is_running())
8282
task:wait()
83-
assert.same(task.output, "foo\n")
83+
assert.same(task:output(), "foo")
8484
assert(task_result.done)
85-
assert(not task.error)
85+
assert(not task:has_errors())
8686
end)
8787

8888
it("spawn 2x", function()
@@ -94,8 +94,8 @@ describe("task", function()
9494
assert(task:is_running())
9595
assert(task:is_running())
9696
task:wait()
97-
assert(task.output == "foo\nbar\n" or task.output == "bar\nfoo\n", task.output)
97+
assert(task:output() == "foo\nbar" or task:output() == "bar\nfoo", task:output())
9898
assert(task_result.done)
99-
assert(not task.error)
99+
assert(not task:has_errors())
100100
end)
101101
end)

0 commit comments

Comments
 (0)