Skip to content

Commit

Permalink
chore: show one accumulated warning instead of multiple warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jun 24, 2024
1 parent 5b89980 commit 512fe7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lua/neotest-golang/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Opts:new(opts)
self.dap_go_enabled = opts.dap_go_enabled or false
self.dap_go_opts = opts.dap_go_opts or {}
self.warn_test_name_dupes = opts.warn_test_name_dupes or true
self.warn_test_not_executed = opts.warn_test_not_executed or true

-- dev options below, not meant for end-users.
self.debug_test_not_associated = opts.debug_test_not_associated or false
Expand All @@ -29,6 +30,7 @@ function Opts:get()
dap_go_enabled = self.dap_go_enabled,
dap_go_opts = self.dap_go_opts,
warn_test_name_dupes = self.warn_test_name_dupes,
warn_test_not_executed = self.warn_test_not_executed,
debug_test_not_associated = self.debug_test_not_associated,
}
end
Expand Down
16 changes: 9 additions & 7 deletions lua/neotest-golang/results_dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,21 @@ function M.show_warnings(d)
)
end

-- warn about duplicate tests
if options.get().warn_test_name_dupes == true then
-- warn about duplicate tests
local test_dupes = {}
for pos_id, test_data in pairs(d) do
if test_data.duplicate_test_detected == true then
vim.notify(
"Duplicate test name detected: "
.. test_data.gotest_data.pkg
.. "/"
.. test_data.gotest_data.name,
vim.log.levels.WARN
table.insert(
test_dupes,
test_data.gotest_data.pkg .. "/" .. test_data.gotest_data.name
)
end
end
vim.notify(
"Duplicate test name(s) detected:\n" .. table.concat(test_dupes, "\n"),
vim.log.levels.WARN
)
end
end

Expand Down

0 comments on commit 512fe7d

Please sign in to comment.