Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow specifying cwd for test_all() #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lua/go/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local function do_fmt(formatter, args)
local original_line = vim.fn.getline('.')
local original_col_nr = vim.fn.col('.')
local cmd = system.wrap_file_command(formatter, args, file_path)
vim.fn.jobstart(cmd, {
local job_id = vim.fn.jobstart(cmd, {
on_exit = function(_, code, _)
if code == 0 then
output.show_success('GoFormat', 'Success')
Expand All @@ -72,6 +72,8 @@ local function do_fmt(formatter, args)
output.show_error('GoFormat', results)
end,
})
-- wait for the job so we don't race nvim writing out the buffer
vim.fn.jobwait({job_id})
end

function M.lsp()
Expand Down
8 changes: 4 additions & 4 deletions lua/go/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local function valid_buf()
return false
end

local function do_test(prefix, cmd)
local function do_test(prefix, cmd, cwd)
if not valid_buf() then
return
end
Expand Down Expand Up @@ -92,7 +92,7 @@ local function do_test(prefix, cmd)
end
end

local cwd = vim.fn.expand('%:p:h')
cwd = cwd or vim.fn.expand('%:p:h')
local env = config.options.test_env
local opts = {
on_exit = function(_, code, _)
Expand Down Expand Up @@ -125,14 +125,14 @@ function M.test()
do_test(prefix, build_args(cmd))
end

function M.test_all()
function M.test_all(cwd)
if not util.binary_exists('go') then
return
end

local prefix = 'GoTestAll'
local cmd = { 'go', 'test', './...' }
do_test(prefix, build_args(cmd))
do_test(prefix, build_args(cmd), cwd)
end

function M.test_func(opt)
Expand Down
Loading