From 206d2080189e44c536d107f15c2ba2dc6fc1b6ea Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 26 Jun 2024 18:42:52 +0200 Subject: [PATCH] test: fix tests --- lua/lazy/manage/runner.lua | 15 ++++++++------- lua/lazy/manage/task/init.lua | 2 +- tests/manage/task_spec.lua | 14 +++++++------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lua/lazy/manage/runner.lua b/lua/lazy/manage/runner.lua index e517ddc..0b0e5c4 100644 --- a/lua/lazy/manage/runner.lua +++ b/lua/lazy/manage/runner.lua @@ -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 diff --git a/lua/lazy/manage/task/init.lua b/lua/lazy/manage/task/init.lua index 496dac9..8c5f83f 100644 --- a/lua/lazy/manage/task/init.lua +++ b/lua/lazy/manage/task/init.lua @@ -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 diff --git a/tests/manage/task_spec.lua b/tests/manage/task_spec.lua index 11487c5..adb01e8 100644 --- a/tests/manage/task_spec.lua +++ b/tests/manage/task_spec.lua @@ -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)