Skip to content

Commit

Permalink
fix(dap-strategy): Removing the need to use the workaround custom debug
Browse files Browse the repository at this point in the history
- Neotest core fixes ability to supply custom strategy function to
  override situation when this adapter is asked to run the "dap"
  strategy
- Adds deprecation warning regarding previous workaround prior to
  deprecation
  • Loading branch information
Adam Figgins committed Jun 20, 2023
1 parent 2f3a524 commit bf5d37d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 13 additions & 1 deletion lua/neotest-dotnet/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ DotnetNeotestAdapter.build_spec = function(args)
logger.debug("neotest-dotnet: Created " .. #specs .. " specs, with contents: ")
logger.debug(specs)

if args.is_custom_dotnet_debug then
if args.is_custom_dotnet_debug or args.strategy == "dap" then
if #specs > 1 then
logger.warn(
"neotest-dotnet: DAP strategy does not support multiple test projects. Please debug test projects or individual tests. Falling back to using default strategy."
Expand All @@ -127,7 +127,19 @@ DotnetNeotestAdapter.build_spec = function(args)
return specs
else
-- Change the strategy to custom netcoredbg strategy and pass in the additional dap args from the user
if args.is_custom_dotnet_debug then
vim.notify(
[[The custom command
'run({strategy = require('neotest-dotnet.strategies.netcoredbg'), is_custom_dotnet_debug true})'
is no longer required.
You can now simply use run({strategy = 'dap'}) to debug your tests.
This custom command will be deprecated in future versions of this adapter.]],
vim.log.levels.WARN,
{ title = "neotest-dotnet" }
)
end
specs[1].dap_args = dap_args
specs[1].strategy = require("neotest-dotnet.strategies.netcoredbg")
end
end

Expand Down
4 changes: 0 additions & 4 deletions lua/neotest-dotnet/strategies/netcoredbg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ return function(spec)
cwd = spec.cwd,
env = { ["VSTEST_HOST_DEBUG"] = "1" },
pty = true,
height = spec.strategy.height,
width = spec.strategy.width,
on_stdout = function(_, data)
nio.run(function()
data_accum:push(table.concat(data, "\n"))
Expand Down Expand Up @@ -114,8 +112,6 @@ return function(spec)
end)
end
attach_win = lib.ui.float.open({
height = spec.strategy.height,
width = spec.strategy.width,
buffer = attach_buf,
})
vim.api.nvim_buf_set_option(attach_buf, "filetype", "neotest-attach")
Expand Down

0 comments on commit bf5d37d

Please sign in to comment.