-
Notifications
You must be signed in to change notification settings - Fork 7
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
Debug test support #9
Comments
Partially implemented in de0bd23 |
I'm working on something related to this, particularly being able to debug individual tests. on your project const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{},
}); and then just add the parameter in the zig build command: https://github.com/fnzr/neotest-zig/blob/1a1800a95d534d9acdc5055dfeab8c8a84b7bdea/lua/neotest-zig/init.lua#L213 Both running and debugging individual tests is working on my machine, but the debug configuration is kinda iffy. I dont know what to put on the run_spec command, since both the build and run must be ran by the debugger (otherwise we'd be debugging an old exe), and I dont know how to capture compilation errors when running under dap. But if the compilation works, we get step debugging on individual tests, whether they fail or not, which is really nice. |
I was aware of the
Instead I'd like debugging to use the same test runner that running tests uses now, where filtering is done via [
{
"source_path": "/Users/llaz/git/zig-enumerable/src/enumerable.zig",
"test_name": "decltest.first",
"output_path": "/var/folders/c2/yvzkyl496hn0bsc37tbc0fqc0000gn/T/nvim.llaz/QGJRcT/0"
}
] I had this mostly working in Also, a few days ago I've become a father, so might be slow to respond, sorry about that! |
Ah, so that's what the input file does! I see, you're absolutely right that's the better approach. I think it's working as intended, I had no issues with it. About debugging, I believe we need a better approach. Currently, the build step is made on the program function of the dap configuration: program = function()
vim.fn.system(
"zig build neotest-build --build-file neotest_build.zig -Dneotest-runner=\"/Users/llaz/git/neotest-zig/zig/neotest_runner.zig\"")
return program_path
end, This almost works, but there are two issues:
I've tried searching, moving around the spec command, passing different dap configurations to the strategy, but nothing quite works reliably on error cases (but as I said, if the program builds fine everything just works). There's the overseer plugin that allows executing a task before running tests, but adding a plugin dependency is obviously not ideal. Congratulations on becoming a father, and don't worry about it, focus on your family! |
You're right. I tried to summarize all that is left to do in regards to debugging at the top of this issue. Let me know if I missed anything. It's not immediately obvious to me how to solve all of these either. We might have to look into how other neotest adapters for other languages have solved these issues. |
A bit of an update. I looked into reporting build errors and not launching debug session, but I dont think that's possible as is. Both golang and rust adapters suffer the same problem and launch the debugger even if the build fails. I opened an issue on neotest expanding on it. I think handling this situation requires either implementing a custom strategy or a upstream patch on neotest. In the meantime, I completed a few tasks from this issue: async building, multiple output support (maybe), notification on build error (not ideal, but better) and user configurable debug adapter. Can I make a pr with these or is it better to wait neotest response? |
Please do! We don't have to resolve everything in a single go |
This implements the following features related to #9: * Adds a configuration to customize the debugger adapter in the setup function * Running the DAP strategy asynchronously builds the project using `nio.control.future` and native lua api (based on [rustacean implementation](https://github.com/mrcjkb/rustaceanvim/blob/2fa45427c01ded4d3ecca72e357f8a60fd8e46d4/lua/rustaceanvim/neotest/init.lua#L277) of the same feature) * Displays an error message on build errors with the `vim.notify` api.
Neotest supports DAP debugging for tests.
Checklist:
build.zig
and withoutbuild.zig
addTests
artifacts frombuild.zig
are namedtest
. If there are multiple, we should warn user to add explicit name to theiraddTests
.gdb
,lldb
,codelldb
)The text was updated successfully, but these errors were encountered: