Skip to content

Commit

Permalink
fix(dap): use test filepath from neotest positions
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Hoehl <[email protected]>
  • Loading branch information
Lukas Hoehl committed Oct 13, 2024
1 parent 33077c3 commit a98ff70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lua/neotest-golang/features/dap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ function M.setup_debugging(cwd)
end
end

--- @param test_path string
--- @param test_name_regex string
--- @return table | nil
function M.get_dap_config(test_name_regex)
function M.get_dap_config(test_path, test_name_regex)
-- :help dap-configuration
local dap_config = {
type = "go",
name = "Neotest-golang",
request = "launch",
mode = "test",
program = "${fileDirname}",
args = { "-test.run", test_name_regex },
program = test_path,
}

local dap_go_opts = options.get().dap_go_opts or {}
Expand Down
6 changes: 3 additions & 3 deletions lua/neotest-golang/runspec/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ local M = {}
--- @param strategy string
--- @return neotest.RunSpec | neotest.RunSpec[] | nil
function M.build(pos, strategy)
local test_folder_absolute_path =
string.match(pos.path, "(.+)" .. lib.find.os_path_sep)
local pos_path_foldername = vim.fn.fnamemodify(pos.path, ":h")
local test_folder_absolute_path = pos_path_foldername

local golist_data, golist_error =
lib.cmd.golist_data(test_folder_absolute_path)
Expand All @@ -36,7 +36,7 @@ function M.build(pos, strategy)
local runspec_strategy = nil
if strategy == "dap" then
M.assert_dap_prerequisites()
runspec_strategy = dap.get_dap_config(test_name_regex)
runspec_strategy = dap.get_dap_config(pos_path_foldername, test_name_regex)
logger.debug("DAP strategy used: " .. vim.inspect(runspec_strategy))
dap.setup_debugging(test_folder_absolute_path)
end
Expand Down

0 comments on commit a98ff70

Please sign in to comment.