From 579c8d52ead6c2b7e88a7290e4aff657916c83e0 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sun, 14 Jul 2024 17:01:00 +0200 Subject: [PATCH] fix: include sub-test in test output --- lua/neotest-golang/process.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lua/neotest-golang/process.lua b/lua/neotest-golang/process.lua index 1c36682b..f2a58087 100644 --- a/lua/neotest-golang/process.lua +++ b/lua/neotest-golang/process.lua @@ -251,6 +251,13 @@ function M.decorate_with_go_package_and_test_name( return res end +function M.starts_with(str, start) + vim.notify( + "str: " .. vim.inspect(str) .. " and start: " .. vim.inspect(start) + ) + return str:sub(1, #start) == start +end + --- Decorate the internal test result data with data from the 'go test' output. --- @param res table --- @param gotest_output table @@ -259,8 +266,10 @@ function M.decorate_with_go_test_results(res, gotest_output) for pos_id, test_data in pairs(res) do for _, line in ipairs(gotest_output) do if - test_data.gotest_data.pkg == line.Package - and test_data.gotest_data.name == line.Test + line.Package ~= nil + and line.Test ~= nil + and line.Package == test_data.gotest_data.pkg + and M.starts_with(line.Test, test_data.gotest_data.name) then -- record test status if line.Action == "pass" then