Skip to content

Commit

Permalink
Add outputMode and customization to test config
Browse files Browse the repository at this point in the history
Recent changes in nvim-dap behavior required setting `outputMode =
"remote"` in debug configs for stdout to be visible in REPL (see
leoluz#108 for more info). The
problem is now fixed for test scenarios too.

`test_debug` now accepts a `custom_config` argument as a way for users
to get around similar problems.
  • Loading branch information
CruelAddict committed Jan 17, 2025
1 parent 1bacf2f commit ee8c690
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/dap-go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function M.setup(opts)
setup_go_configuration(dap, internal_global_config)
end

local function debug_test(testname, testpath, build_flags, extra_args)
local function debug_test(testname, testpath, build_flags, extra_args, custom_config)
local dap = load_module("dap")

local config = {
Expand All @@ -204,7 +204,9 @@ local function debug_test(testname, testpath, build_flags, extra_args)
program = testpath,
args = { "-test.run", "^" .. testname .. "$" },
buildFlags = build_flags,
outputMode = "remote",
}
config = vim.tbl_deep_extend("force", config, custom_config or {})

if not vim.tbl_isempty(extra_args) then
table.move(extra_args, 1, #extra_args, #config.args + 1, config.args)
Expand All @@ -213,7 +215,7 @@ local function debug_test(testname, testpath, build_flags, extra_args)
dap.run(config)
end

function M.debug_test()
function M.debug_test(custom_config)
local test = ts.closest_test()

if test.name == "" or test.name == nil then
Expand All @@ -232,7 +234,7 @@ function M.debug_test()
extra_args = { "-test.v" }
end

debug_test(test.name, test.package, M.test_buildflags, extra_args)
debug_test(test.name, test.package, M.test_buildflags, extra_args, custom_config)

return true
end
Expand Down

0 comments on commit ee8c690

Please sign in to comment.