From 66e99e3f68689c35cbc3dbf26c2177ee3e394e99 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Wed, 7 Aug 2024 17:36:36 +0200 Subject: [PATCH 1/2] fix: log tables using linebreaks and tabs for easier reading --- lua/neotest-golang/logging.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/neotest-golang/logging.lua b/lua/neotest-golang/logging.lua index 3cd8fdc6..c9abe9bd 100644 --- a/lua/neotest-golang/logging.lua +++ b/lua/neotest-golang/logging.lua @@ -13,11 +13,6 @@ local function clean_output(str) return str end -local function table_to_string(tbl) - local result = vim.inspect(tbl) - return clean_output(result) -end - ---@param input any ---@return string local function handle_input(input) @@ -27,7 +22,7 @@ local function handle_input(input) local result = "" for _, v in ipairs(input) do if type(v) == "table" then - result = result .. table_to_string(v) .. " " + result = result .. vim.inspect(v) .. " " elseif type(v) == "string" then result = result .. clean_output(v) .. " " else From 32ded373e07123d61ce06d961ce0878f963d4604 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Wed, 7 Aug 2024 17:36:49 +0200 Subject: [PATCH 2/2] chore(logging): enable more debug logging --- lua/neotest-golang/process.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/neotest-golang/process.lua b/lua/neotest-golang/process.lua index 96199479..2d836be9 100644 --- a/lua/neotest-golang/process.lua +++ b/lua/neotest-golang/process.lua @@ -79,11 +79,14 @@ function M.test_results(spec, result, tree) elseif runner == "gotestsum" then raw_output = async.fn.readfile(context.test_output_json_filepath) end + logger.debug({ "Raw 'go test' output: ", raw_output }) local gotest_output = lib.json.decode_from_table(raw_output) + logger.debug({ "Parsed 'go test' output: ", gotest_output }) --- The 'go list -json' output, converted into a lua table. local golist_output = context.golist_data + logger.debug({ "Parsed 'go list' output: ", golist_output }) --- @type table local neotest_result = {} @@ -118,8 +121,7 @@ function M.test_results(spec, result, tree) --- @type table local res = M.aggregate_data(tree, gotest_output, golist_output) - -- DEBUG: enable the following to see the internal test result data. - -- logger.debug(vim.inspect(res)) + logger.debug({ "Final internal test result data", res }) -- show various warnings M.show_warnings(res) @@ -130,8 +132,7 @@ function M.test_results(spec, result, tree) neotest_result[k] = v end - -- DEBUG: enable the following to see the final Neotest result. - -- logger.debug(vim.inspect(neotest_result)) + logger.debug({ "Final Neotest result data", neotest_result }) return neotest_result end