bugfix for releative path for `GoTest -c`

pull/125/head
ray-x 2 years ago
parent 6d2062c3d7
commit 0916cb3da1

@ -132,7 +132,7 @@ function go.setup(cfg)
-- e.g. GoTestFile unit
vim.cmd([[command! -nargs=* GoTestFile lua require('go.gotest').test_file(<f-args>)]])
vim.cmd([[command! -nargs=* GoTestPkg lua require('go.gotest').test_package(<f-args>)]])
vim.cmd([[command! -nargs=* -complete=custom,v:lua.package.loaded.go.package_complete GoTestPkg lua require('go.gotest').test_package(<f-args>)]])
vim.cmd([[command! -nargs=* GoAddTest lua require("go.gotests").fun_test(<f-args>)]])
vim.cmd([[command! -nargs=* GoAddExpTest lua require("go.gotests").exported_test(<f-args>)]])
vim.cmd([[command! -nargs=* GoAddAllTest lua require("go.gotests").all_test(<f-args>)]])

@ -159,6 +159,7 @@ function test_arg(arg)
local optarg
local optind
arg = arg or { "-t", "-r", "-c", "path1", "-g", "unit,integration", "path" }
-- arg = arg or { "-t", "-r", "-c", "-g", "unit,integration" }
opts, optind, optarg, unparsed = alt_getopt.get_ordered_opts(arg, "cg:hvo:n:rS:st", long_opts)
print("ordered opts")

@ -78,13 +78,15 @@ local function run_test(path, args)
local bench = false
local optarg, optind, reminder = getopt.get_opts(args, short_opts, long_opts)
if optarg["c"] then
path = "." .. sep .. vim.fn.expand("%:h") -- vim.fn.expand("%:p:h") can not resolve releative path
path = utils.rel_path() -- vim.fn.expand("%:p:h") can not resolve releative path
compile = true
end
if optarg["b"] then
bench = true
end
if next(reminder) then
path = reminder[1]
end
local test_runner = _GO_NVIM_CFG.go
if _GO_NVIM_CFG.test_runner ~= test_runner then
test_runner = _GO_NVIM_CFG.test_runner
@ -175,10 +177,8 @@ M.test_package = function(...)
local args = { ... }
log(args)
local repath = utils.rel_path() or ""
local repath = utils.rel_path() or "."
local fpath = repath .. utils.sep() .. "..."
utils.log("fpath: " .. fpath)
-- args[#args + 1] = fpath
@ -222,7 +222,7 @@ M.test_fun = function(...)
end
if _GO_NVIM_CFG.verbose_tests then
table.insert("-v")
table.insert(cmd, "-v")
end
if not empty(tags) then

@ -32,6 +32,12 @@ local function binary_check()
if no_err then
ok("All binaries installed")
end
if vim.fn.executable('sed') == 1 then
info("sed installed.")
else
warn("sed is not installed.")
end
end
local function plugin_check()

@ -410,10 +410,11 @@ end
function util.rel_path()
local fpath = vim.fn.expand("%:p:h")
local workfolders = vim.lsp.buf.list_workspace_folders()
if workfolder ~= nil then
fpath = "." .. fpath:sub(#workfolder + 1)
if workfolders ~= nil and next(workfolders) then
fpath = "." .. fpath:sub(#workfolders[1] + 1)
end
return fpath
end

Loading…
Cancel
Save