From d725371c42c74f213d915326c8fc6a82cdb8da32 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Thu, 12 Jun 2025 17:30:36 -0400 Subject: [PATCH] debugger: Pass --nocapture to cargo tests when building debug tasks with locator (#32633) Release Notes: - Add --nocapture as a default argument when debugging rust tests Co-authored-by: Cole Miller --- crates/project/src/debugger/locators/cargo.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/project/src/debugger/locators/cargo.rs b/crates/project/src/debugger/locators/cargo.rs index 5c43f02213b120cd06be967b98456d68dedc4948..7e3b4a506dcfec5d8c04e9ca57a7bb2d86f98cff 100644 --- a/crates/project/src/debugger/locators/cargo.rs +++ b/crates/project/src/debugger/locators/cargo.rs @@ -57,10 +57,10 @@ impl DapLocator for CargoLocator { } match cargo_action.as_ref() { - "run" => { + "run" | "r" => { *cargo_action = "build".to_owned(); } - "test" | "bench" => { + "test" | "t" | "bench" => { let delimiter = task_template .args .iter() @@ -133,7 +133,10 @@ impl DapLocator for CargoLocator { !executables.is_empty(), "Couldn't get executable in cargo locator" ); - let is_test = build_config.args.first().map_or(false, |arg| arg == "test"); + let is_test = build_config + .args + .first() + .map_or(false, |arg| arg == "test" || arg == "t"); let mut test_name = None; if is_test { @@ -161,7 +164,10 @@ impl DapLocator for CargoLocator { anyhow::bail!("Couldn't get executable in cargo locator"); }; - let args = test_name.into_iter().collect(); + let mut args: Vec<_> = test_name.into_iter().collect(); + if is_test { + args.push("--nocapture".to_owned()); + } Ok(DebugRequest::Launch(task::LaunchRequest { program: executable,