nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.12k stars 105 forks source link

Graciously handling DAP failure on multistep (build then run) languages #415

Open fnzr opened 1 month ago

fnzr commented 1 month ago

Hello! I'm working on improving the DAP handling on the zig adapter, and we are exploring how to handle build errors.

When running tests with integrated strategy, we have a nice feedback on compile errors:

2024-06-02-12:10:36-screenshot

We are now trying to figure out how to do something similar when using the dap strategy.

Languages that require building before running tests can fail in either step, and when using the dap strategy, I don't see any way to gracefully handle it: the the debugger is always launched in a invalid state.

This is not a zig specific issue, it happens with the golang adapter:

2024-06-02-12:03:52-screenshot

The rust adapter does its best to identify and report build errors, but can't do anything about it, and the debugger is also launched in an invalid state:

2024-06-02-12:04:34-screenshot

As I understand it, there's nothing the adapter can do about this problem. The dap strategy expects a dap configuration, and not providing it results in either a "adapter doesn't support the dap strategy" message, some cryptic configuration error, or launching the debugger in a bad state, because the strategy handler either expects nothing, or just launches.

(here) https://github.com/nvim-neotest/neotest/blob/6f35d797882c6ce0ab7c87dc86561512dc3d7aba/lua/neotest/client/strategies/dap/init.lua#L27

It would be nice if the adapters could somehow report to the strategy handler that "hey, something bad happened, do not launch the debugger"

Does this feature exists (maybe I'm just missing it)? If not, would it be doable?

rcarriga commented 3 weeks ago

The feature doesn't currently exist but happy to take PRs for the dap strategy to be able to show these kind of errors and not run the debugger :smile: