Skip to content

Commit

Permalink
feat: only check auto-determined func name
Browse files Browse the repository at this point in the history
Rationale is that the user is able to provide their own value for `func_name`
in `opt.func` and thus should be fully responsible to provide a valid name.

This allows e.g. to provide a specific sub-test-name for table-driven tests.
  • Loading branch information
wilriker authored and crispgm committed Mar 9, 2024
1 parent e41216a commit a59e9a7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lua/go/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,20 @@ function M.test_func(opt)
end
local cur_line = vim.fn.getline(line)
func_name = split_file_name(cur_line)
end
if not valid_func_name(func_name) then
output.show_error(
'GoTestFunc',
string.format('Invalid test func: %s', func_name)
)
return
if not valid_func_name(func_name) then
output.show_error(
'GoTestFunc',
string.format('Invalid test func: %s', func_name)
)
return
end
func_name = vim.fn.shellescape(string.format('^%s$', func_name))
end
local cmd = {
'go',
'test',
'-run',
vim.fn.shellescape(string.format('^%s$', func_name)),
func_name,
}
do_test(prefix, build_args(cmd))
end
Expand Down

0 comments on commit a59e9a7

Please sign in to comment.