Skip to content

Commit

Permalink
feat(errors): add errors to quichfix list
Browse files Browse the repository at this point in the history
  • Loading branch information
Su3h7aM committed Dec 28, 2024
1 parent 675fc08 commit 2207569
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions lua/neotest-odin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ function odin.adapter.build_spec(args)
.. position.pkg
.. "."
.. position.name
.. flags,
.. flags
.. " > /dev/null",
context = {
name = position.name,
id = position.id,
Expand Down Expand Up @@ -178,6 +179,35 @@ function odin.adapter.results(spec, result, tree)
-- local line = output:read("*a")
-- output:close()

local sucess, file = pcall(lib.files.read_lines, result.output)

if not sucess then
lib.notify("Error reading file: " .. result.output)
end

local n_errors = 1
local errors = {}
local short = ""
for _, line in ipairs(file) do
local is_error = line:match("%[ERROR%]")
local is_finished = line:match("Finished")

if is_error then
local file_name, err_line, proc, msg = line:match("%[(%w-[_%w]%w-%.odin):(%d-):(%w-[_%w]%w-)%(%)%]%s(.*)")

errors[n_errors] = {
message = msg,
line = tonumber(err_line) - 1,
}

n_errors = n_errors + 1
end

if is_finished then
short = line
end
end

local status = "failed"
if result.code == 0 then
status = "passed"
Expand All @@ -188,10 +218,8 @@ function odin.adapter.results(spec, result, tree)
[spec.context.id] = {
status = status,
output = result.output,
-- short = "testando: ola",
-- errors = {
-- { message = "erro", line = 5 },
-- },
short = short,
errors = errors,
},
}

Expand Down

0 comments on commit 2207569

Please sign in to comment.