Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jul 22, 2024
1 parent d1642e8 commit 2e4e703
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
5 changes: 2 additions & 3 deletions lua/neotest-golang/logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ local prefix = "[neotest-golang] "

local function clean_output(str)
-- Replace escaped newlines and tabs with spaces
-- FIXME: commented out temporarily
-- str = str:gsub("[\n\t]", " ")
str = str:gsub("[\n\t]", " ")
-- Collapse multiple spaces into one
-- str = str:gsub("%s+", " ")
str = str:gsub("%s+", " ")
return str
end

Expand Down
13 changes: 2 additions & 11 deletions lua/neotest-golang/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ function M.test_results(spec, result, tree)
raw_output = async.fn.readfile(context.test_output_json_filepath)
end

logger.debug({ "Raw output from readfile", raw_output })
local gotest_output = lib.json.decode_from_table(raw_output)
logger.debug({ "Table JSON-decoded", gotest_output })

--- The 'go list -json' output, converted into a lua table.
local golist_output = context.golist_data
Expand Down Expand Up @@ -133,7 +131,8 @@ function M.test_results(spec, result, tree)
end

-- DEBUG: enable the following to see the final Neotest result.
logger.debug(vim.inspect(res))
-- logger.debug(vim.inspect(res))
-- logger.debug(vim.inspect(neotest_result))

return neotest_result
end
Expand Down Expand Up @@ -218,7 +217,6 @@ function M.decorate_with_go_package_and_test_name(
local folderpath = vim.fn.fnamemodify(test_data.neotest_data.path, ":h")
local tweaked_pos_id = pos_id:gsub(" ", "_")
tweaked_pos_id = tweaked_pos_id:gsub('"', "")
-- tweaked_pos_id = tweaked_pos_id:gsub("\\", "/") -- FIXME: just testing this for windows
tweaked_pos_id = tweaked_pos_id:gsub("::", "/")

for _, golistline in ipairs(golist_output) do
Expand All @@ -234,16 +232,9 @@ function M.decorate_with_go_package_and_test_name(
.. "$"
match = tweaked_pos_id:find(pattern, 1, false)

logger.debug({
"Match position with log",
tweaked_pos_id,
pattern,
})

if match ~= nil then
test_data.gotest_data.pkg = gotestline.Package
test_data.gotest_data.name = gotestline.Test
logger.debug("MATCH")
break
end
end
Expand Down
3 changes: 1 addition & 2 deletions lua/neotest-golang/runspec/dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ function M.build(pos)
return nil -- NOTE: logger.error will throw an error, but the LSP doesn't see it.
end

logger.debug({ "Go mod filepath", go_mod_filepath })

local go_mod_folderpath = vim.fn.fnamemodify(go_mod_filepath, ":h")
local golist_data = lib.cmd.golist_data(go_mod_folderpath)

Expand Down Expand Up @@ -59,6 +57,7 @@ function M.build(pos)
context = context,
}

logger.debug({ "RunSpec:", run_spec })
return run_spec
end

Expand Down
3 changes: 1 addition & 2 deletions lua/neotest-golang/runspec/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ function M.build(pos, tree)
return nil -- NOTE: logger.error will throw an error, but the LSP doesn't see it.
end

logger.debug({ "Go mod filepath", go_mod_filepath })

local go_mod_folderpath = vim.fn.fnamemodify(go_mod_filepath, ":h")
local golist_data = lib.cmd.golist_data(go_mod_folderpath)

Expand Down Expand Up @@ -73,6 +71,7 @@ function M.build(pos, tree)
context = context,
}

logger.debug({ "RunSpec:", run_spec })
return run_spec
end

Expand Down
1 change: 1 addition & 0 deletions lua/neotest-golang/runspec/namespace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function M.build(pos)
context = context,
}

logger.debug({ "RunSpec:", run_spec })
return run_spec
end

Expand Down

0 comments on commit 2e4e703

Please sign in to comment.