Debugging tests?

I’m using VS Code + ZLS for working with Zig.

I am able to successfully debug code using the instructions here: Debugging Zig with VS Code - DEV Community

However, anyone has ideas about how I can get debugging of tests to work? Ideally, I can specify which test I’m looking at and run it in the debugger.

Alternatively, I’m fine with just being able to call the test function from main.zig directly, but I’m not sure how that can be done.

Someone asked pretty much the same question on Matrix some time ago, so let me copy/paste from that thread:

Hello! Does anyone know if I can debug tests with gdb/lldb?

yes, with a bit of effort. if you’re using the Zig build system, a test executable will be created somewhere in zig-cache:

$ find ./zig-cache -executable -name test

then you can run it:

$ gdb --args ./zig-cache/o/667f8030f64ccfa76e412866f585be83/test $(which zig)
1 Like

IIRC there’s a flag to make zig test produce an executable where you want it to, so that should simplify part of the process described by jmc.