fix(gotest): wrong order of test binary args (#230)

Co-authored-by: Roy Choo <roy.choo@bytedance.com>
pull/234/head
Roy Choo 2 years ago committed by GitHub
parent 7720ddcbea
commit 6602986054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -172,11 +172,6 @@ function M.make(...)
log("run test", efm)
table.insert(cmd, "-run")
end
if optarg["a"] then
log("extra args", optarg["a"])
table.insert(cmd, "-args")
table.insert(cmd, optarg["a"])
end
if not bench and compile_test then
table.insert(cmd, "-c")
end
@ -188,6 +183,11 @@ function M.make(...)
cmd = vim.list_extend(cmd, reminder)
end
if optarg["a"] then
table.insert(cmd, "-args")
table.insert(cmd, optarg["a"])
end
local function handle_color(line)
if _GO_NVIM_CFG.run_in_floaterm or optarg["F"] then
return line
@ -273,7 +273,7 @@ function M.make(...)
end
if next(errorlines) ~= nil and runner == "golangci-lint" then
efm =
[[level=%tarning\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%tarning\ msg="%m",level=%trror\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%trror\ msg="%m",%f:%l:%c:\ %m,%f:%l:\ %m,%f:%l\ %m]]
[[level=%tarning\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%tarning\ msg="%m",level=%trror\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%trror\ msg="%m",%f:%l:%c:\ %m,%f:%l:\ %m,%f:%l\ %m]]
end
end

@ -42,6 +42,24 @@ describe("should run func test", function()
eq({ "go", "test", "-v", "-run", [['^Test_branch$']], "./lua/tests/fixtures/coverage" }, cmd)
end)
it("should test function with additional args to test binary", function()
--
-- go.nvim may not auto loaded
vim.cmd([[packadd go.nvim]])
local path = cur_dir .. "/lua/tests/fixtures/coverage/branch_test.go" -- %:p:h ? %:p
require("go").setup({
trace = true,
lsp_cfg = true,
log_path = vim.fn.expand("$HOME") .. "/tmp/gonvim.log",
test_runner = "go",
})
vim.cmd("silent exe 'e " .. path .. "'")
vim.fn.setpos(".", { 0, 5, 11, 0 })
local cmd = require("go.gotest").test_func("-a", "mock=true")
eq({ "go", "test", "-v", "-run", [['^Test_branch$']], "./lua/tests/fixtures/coverage", "-args", "mock=true" }, cmd)
end)
end)
describe("should run test file", function()

Loading…
Cancel
Save