debuggingrustsublimetextrust-cargo

How to debug unit tests in Rust using Sublime Debugger?


I am trying to debug unit tests in Rust using the Debugger package in Sublime. I have the following debugger configuration in my sublime project:

    "debugger_configurations":
    [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Cargo test",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--lib",
                ]
            },
            "program": "${workspaceRoot}/target/debug/projectName",
            "args": []
        },
    ],

When I start debugging, the debugger drops into the main function in the file rather than the unit tests. This link says to use cargo instead of program in VSCode (the Debugger package is essentially a port of the VSCode debugger to Sublime) but the Debugger package will not run without program and seems to ignore the cargo field altogether.

I'm beginning to think this is an actual problem with the Debugger package, but either way, I figured I would ask here before filing an issue there. Do I have something misconfigured, or is there an alternative way of debugging Rust unit tests in Sublime?


Solution

  • I was able to make things work by adding "program": "${workspaceRoot}/target/debug/deps/projectName-SHA" where the SHA is found from the output of cargo test --no-run. It's not ideal but it works!