Closed sveatlo closed 1 year ago
I've been debugging this some more and I've found out, that running cargo test
in dap.lua:start(...)
outputs 3 (in this case) "compiler artifacts". These artifacts contain both the main executable and the specific test I want to run, but the order seem to be nondeterministic and therefore whichever artifact with non-nil executable
property is first gets executed (artifacts with nil executable are filtered out)
I have a minimal example project with a
main.rs
andlib.rs
files insrc
directory andadding.rs
file intests
directorylib.rs
contains aadd
function which just returns the sum of 2 numbersmain.rs
calls this function with 2 numbers and prints the resulttests/addition.rs
contains a single testWhen I call
:RustDebuggables
and selecttest --no-run --package tests-debug-dap-async --test addition -- test_add --nocapture
it often runs the main program in the debugger outputting:It doesn't happen all the time and rerunning the debuggable it eventually gets to running the test, but rerunning it again (maybe couple of times) gets me back to running the main program.
I've turned on dap debugging using
:DapSetLogLevel TRACE
and here are the output logs: incorrect case, correct case. In the "incorrect" case's "request" log line, you can clearly see it is runningtarget/debug/tests-debug-dap-async
instead oftarget/debug/deps/addition-acbfb4ac66cbe508
even though they were started using the same debuggable command.Gist with the code used: https://gist.github.com/sveatlo/3573851140184a9a3e890526c8d6cdfa
EDIT: It seems it may also happen with other debuggable test types. I've managed to get the same results with both
test --no-run --package tests-debug-dap-async --all-targets
andtest --no-run --package tests-debug-dap-async --test addition -- --nocapture
EDIT 2: I forgot to add that I'm using
codelldb
, but results are consistent withlldb-vscode
.