Skip to content

Commit

Permalink
feat: warn more prominently about 'go list' error
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Nov 30, 2024
1 parent 45bd765 commit 50e6ebe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lua/neotest-golang/lib/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function M.golist_data(cwd)
if result.stdout ~= nil and result.stderr ~= "" then
err = err .. " " .. result.stderr
end
logger.debug({ "Go list error: ", err })
logger.warn({ "Go list error: ", err })
end

local output = result.stdout or ""
Expand All @@ -42,7 +42,7 @@ function M.golist_command()
go_list_args = go_list_args()
end
vim.list_extend(cmd, go_list_args or {})
vim.list_extend(cmd, { "./..." })
vim.list_extend(cmd, { "foo" })
return cmd
end

Expand Down
16 changes: 11 additions & 5 deletions lua/neotest-golang/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function M.test_results(spec, result, tree)
--- @type table
local gotest_output = lib.json.decode_from_table(runner_raw_output, true)

-- detect go list error
local golist_failed = false
if context.errors ~= nil and #context.errors > 0 then
golist_failed = true
end

-- detect build error
local build_failed = M.detect_build_errors(result, raw_output)
local build_failure_lookup = {}
Expand All @@ -94,8 +100,8 @@ function M.test_results(spec, result, tree)

logger.debug({ "Final internal test result data", res })

-- show various warnings
if not build_failed then
-- show various warnings, unless `go list` failed or build failed.
if not golist_failed and not build_failed then
M.show_warnings(res)
end

Expand All @@ -117,14 +123,14 @@ function M.test_results(spec, result, tree)
if build_failed then
-- mark as failed if the build failed.
result_status = "failed"
elseif context.errors ~= nil and #context.errors > 0 then
-- mark as failed if a non-gotest error occurred.
result_status = "failed"
elseif
neotest_result[pos.id] and neotest_result[pos.id].status == "skipped"
then
-- keep the status if it was already decided to be skipped.
result_status = "skipped"
elseif context.errors ~= nil and #context.errors > 0 then
-- mark as failed if a non-gotest error occurred.
result_status = "failed"
elseif result.code > 0 then
-- mark as failed if the go test command failed.
result_status = "failed"
Expand Down

0 comments on commit 50e6ebe

Please sign in to comment.