fix TSamFailedOnly and the output formatting for the go-runner

This commit is contained in:
2025-12-25 17:27:30 +01:00
parent 1e2e881acd
commit 2c2cb35953
6 changed files with 443 additions and 2 deletions

View File

@@ -201,6 +201,22 @@ function runner.build_file_command(bufnr)
local spec = { file = path, cwd = root }
local pkg = build_pkg_arg(spec)
local cmd = { "go", "test", "-json", pkg }
local lines = util.get_buf_lines(bufnr)
local funcs = find_test_functions(lines)
local names = {}
for _, fn in ipairs(funcs) do
table.insert(names, fn.name)
end
names = collect_unique(names)
if #names > 0 then
local pattern_parts = {}
for _, name in ipairs(names) do
table.insert(pattern_parts, escape_go_regex(name))
end
local pattern = "^(" .. table.concat(pattern_parts, "|") .. ")$"
table.insert(cmd, "-run")
table.insert(cmd, pattern)
end
return {
cmd = cmd,
cwd = root,