Build tags deduplicate

gh_action
ray-x 2 months ago
parent cd698756e1
commit 3251ea1756

@ -31,7 +31,7 @@ local bench_opts = { '-benchmem', '-cpuprofile', 'profile.out' }
local is_windows = utils.is_windows()
local is_git_shell = is_windows
and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil)
and (vim.fn.exists('$SHELL') and vim.fn.expand('$SHELL'):find('bash.exe') ~= nil)
M.efm = function()
local indent = [[%\\%( %\\)]]
local efm = [[%-G=== RUN %.%#]]
@ -54,7 +54,7 @@ M.efm = function()
efm = efm .. ',%A%f:%l:%c: %m'
efm = efm .. ',%A%f:%l: %m'
efm = efm .. ',%f:%l +0x%[0-9A-Fa-f]%\\+' -- pannic with adress
efm = efm .. ',%f:%l +0x%[0-9A-Fa-f]%\\+' -- pannic with adress
efm = efm .. ',%-G%\\t%\\f%\\+:%\\d%\\+ +0x%[0-9A-Fa-f]%\\+' -- test failure, address invalid inside
-- multi-line
efm = efm .. ',%+G%\\t%m'
@ -79,7 +79,6 @@ M.get_build_tags = function(args, tbl)
end
local optarg, _, reminder = getopt.get_opts(args, short_opts, long_opts)
log('build tags', optarg, reminder)
if optarg['t'] then
table.insert(tags, optarg['t'])
end
@ -93,6 +92,8 @@ M.get_build_tags = function(args, tbl)
if _GO_NVIM_CFG.test_runner == 'dlv' then
t = '--build-flags'
end
log('build tags', tags, args, optarg, reminder)
if #tags > 0 then
if tbl then
return { t, table.concat(tags, ',') }, reminder, optarg
@ -423,7 +424,6 @@ M.get_testcase_name = function()
return nil
end
local function format_test_name(name)
name = name:gsub('"', '')
@ -456,7 +456,7 @@ local function run_tests_with_ts_node(args, func_node, tblcase_ns)
local test_name_path = format_test_name(func_node.name)
if tblcase_ns then
test_name_path = test_name_path .. "/" .. format_test_name(tblcase_ns)
test_name_path = test_name_path .. '/' .. format_test_name(tblcase_ns)
end
if func_node.name:find('Bench') then
@ -478,7 +478,7 @@ local function run_tests_with_ts_node(args, func_node, tblcase_ns)
end
if test_runner == 'dlv' then
local runflag = string.format("-test.run=%s", test_name_path)
local runflag = string.format('-test.run=%s', test_name_path)
table.insert(cmd, 3, fpath)
table.insert(cmd, '--')
table.insert(cmd, runflag)
@ -557,8 +557,8 @@ M.get_test_cases = function()
return
end
local cmd = [[cat ]]
.. fpath
.. [[| sed -n 's/func\s\+\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\|/g']]
.. fpath
.. [[| sed -n 's/func\s\+\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\|/g']]
local tests_results = vfn.systemlist(cmd)
if vim.v.shell_error ~= 0 then
utils.warn('go test failed' .. cmd .. vim.inspect(tests_results))

@ -282,7 +282,6 @@ local function fs_write(path, data)
end)
end
local cache_dir = fn.stdpath('cache')
util.log = function(...)
if not _GO_NVIM_CFG or not _GO_NVIM_CFG.verbose then
@ -766,7 +765,9 @@ function util.get_build_tags(buf)
local t = vim.fn.substitute(line, pattern, [[\1]], '')
if t ~= line then -- tag found
t = vim.fn.substitute(t, [[ \+]], ',', 'g')
table.insert(tags, t)
if not vim.tbl_contains(tags, t) then
table.insert(tags, t)
end
end
end
if #tags > 0 then

Loading…
Cancel
Save