From 512fe7ddc0cdacd3b5eabcabd11db328c6958256 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Mon, 24 Jun 2024 17:53:20 +0200 Subject: [PATCH] chore: show one accumulated warning instead of multiple warnings --- lua/neotest-golang/options.lua | 2 ++ lua/neotest-golang/results_dir.lua | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lua/neotest-golang/options.lua b/lua/neotest-golang/options.lua index 83412541..e459f8df 100644 --- a/lua/neotest-golang/options.lua +++ b/lua/neotest-golang/options.lua @@ -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 @@ -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 diff --git a/lua/neotest-golang/results_dir.lua b/lua/neotest-golang/results_dir.lua index caefea7d..5800215f 100644 --- a/lua/neotest-golang/results_dir.lua +++ b/lua/neotest-golang/results_dir.lua @@ -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