Skip to content

Commit

Permalink
refactor: go list
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jul 3, 2024
1 parent 6082e18 commit f0eb9da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lua/neotest-golang/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ local options = require("neotest-golang.options")

local M = {}

function M.golist_cmd(cwd)
function M.golist_cmd_results(cwd)
-- call 'go list -json ./...' to get test file data
local go_list_command = {
"go",
"list",
"-json",
"./...",
}
local go_list_command_result =
local cmd_results =
vim.fn.system("cd " .. cwd .. " && " .. table.concat(go_list_command, " "))
return go_list_command_result
return cmd_results
end

function M.fallback_to_go_test(executable)
Expand Down
4 changes: 2 additions & 2 deletions lua/neotest-golang/runspec_dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function M.build(pos)
end

local go_mod_folderpath = vim.fn.fnamemodify(go_mod_filepath, ":h")
local go_list_command = cmd.golist_cmd(go_mod_folderpath)
local golist_output = json.process_golist_output(go_list_command)
local go_list_results = cmd.golist_cmd_results(go_mod_folderpath)
local golist_output = json.process_golist_output(go_list_results)

-- find the go module that corresponds to the go_mod_folderpath
local module_name = "./..." -- if no go module, run all tests at the $CWD
Expand Down
4 changes: 2 additions & 2 deletions lua/neotest-golang/runspec_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ local M = {}
function M.build(pos, strategy)
--- @type string
local test_folder_absolute_path = string.match(pos.path, "(.+)/")
local go_list_command = cmd.golist_cmd(test_folder_absolute_path)
local golist_output = json.process_golist_output(go_list_command)
local go_list_results = cmd.golist_cmd_results(test_folder_absolute_path)
local golist_output = json.process_golist_output(go_list_results)

--- @type string
local test_name = convert.to_gotest_test_name(pos.id)
Expand Down

0 comments on commit f0eb9da

Please sign in to comment.