Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include sub-test output in test output #133

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/neotest-golang/lib/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ M.convert = require("neotest-golang.lib.convert")
M.cmd = require("neotest-golang.lib.cmd")
M.find = require("neotest-golang.lib.find")
M.json = require("neotest-golang.lib.json")
M.string = require("neotest-golang.lib.string")

return M
13 changes: 13 additions & 0 deletions lua/neotest-golang/lib/string.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local M = {}

---Check if a string starts with a given prefix.
---@param str string
---@param prefix string
function M.starts_with(str, prefix)
if str == nil or prefix == nil then
return false
end
return str:sub(1, #prefix) == prefix
end

return M
10 changes: 8 additions & 2 deletions lua/neotest-golang/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,14 @@ 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 == test_data.gotest_data.pkg
and (
line.Test == test_data.gotest_data.name
or lib.string.starts_with(
line.Test,
test_data.gotest_data.name .. "/"
)
)
then
-- record test status
if line.Action == "pass" then
Expand Down
Loading