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

fix(dap): use test filepath from neotest positions #202

Merged
merged 1 commit into from
Oct 14, 2024
Merged
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
fix(dap): use test filepath from neotest positions
Signed-off-by: Lukas Hoehl <[email protected]>
Lukas Hoehl authored and fredrikaverpil committed Oct 14, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 797f37750e0d4696ce5497a5cf39408012ab3ac3
5 changes: 3 additions & 2 deletions lua/neotest-golang/features/dap/init.lua
Original file line number Diff line number Diff line change
@@ -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 {}
6 changes: 3 additions & 3 deletions lua/neotest-golang/runspec/test.lua
Original file line number Diff line number Diff line change
@@ -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)
@@ -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