Hi,
Here’s my setup, roughly, you might need some adjustments as this is for linux.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "debug_ut",
"program": "./zig-out/bin/ut",
"cwd": "${workspaceRoot}",
"preLaunchTask": "build_ut",
},
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build_ut",
"type": "shell",
"command": "zig test -femit-bin=zig-out/bin/ut --test-no-exec src/ut.zig",
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
The magic is in the extra args to zig test, which prevents the test execution during the build step, and also emit an executable I can launch and debug.
also it’s unclear what exe I need to pick as there can be multiple test.exe files.
Here, I’m compiling tests for src/ut.zig, which includes the other files I want to test, alternatively, you can copy paste the blocks in tasks.json/launch.json to instead build/debug tests in a specific file.
My ut.zig looks like:
comptime {
_ = @import("file1.zig");
_ = @import("file2.zig");
// ...
}