debugger: Fix up Rust test tasks definitions (#30232)
Closes #ISSUE Release Notes: - N/A --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
3cc8850a58
commit
ee56706d15
8 changed files with 53 additions and 27 deletions
|
@ -283,13 +283,14 @@ impl DapStore {
|
|||
pub fn debug_scenario_for_build_task(
|
||||
&self,
|
||||
build: TaskTemplate,
|
||||
adapter: SharedString,
|
||||
adapter: DebugAdapterName,
|
||||
label: SharedString,
|
||||
cx: &mut App,
|
||||
) -> Option<DebugScenario> {
|
||||
DapRegistry::global(cx)
|
||||
.locators()
|
||||
.values()
|
||||
.find_map(|locator| locator.create_scenario(&build, &adapter))
|
||||
.find_map(|locator| locator.create_scenario(&build, &label, adapter.clone()))
|
||||
}
|
||||
|
||||
pub fn run_debug_locator(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use anyhow::{Result, anyhow};
|
||||
use async_trait::async_trait;
|
||||
use dap::{DapLocator, DebugRequest};
|
||||
use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};
|
||||
use gpui::SharedString;
|
||||
use serde_json::Value;
|
||||
use smol::{
|
||||
|
@ -41,7 +41,12 @@ impl DapLocator for CargoLocator {
|
|||
fn name(&self) -> SharedString {
|
||||
SharedString::new_static("rust-cargo-locator")
|
||||
}
|
||||
fn create_scenario(&self, build_config: &TaskTemplate, adapter: &str) -> Option<DebugScenario> {
|
||||
fn create_scenario(
|
||||
&self,
|
||||
build_config: &TaskTemplate,
|
||||
resolved_label: &str,
|
||||
adapter: DebugAdapterName,
|
||||
) -> Option<DebugScenario> {
|
||||
if build_config.command != "cargo" {
|
||||
return None;
|
||||
}
|
||||
|
@ -70,9 +75,9 @@ impl DapLocator for CargoLocator {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
let label = format!("Debug `{}`", build_config.label);
|
||||
let label = format!("Debug `{resolved_label}`");
|
||||
Some(DebugScenario {
|
||||
adapter: adapter.to_owned().into(),
|
||||
adapter: adapter.0,
|
||||
label: SharedString::from(label),
|
||||
build: Some(BuildTaskDefinition::Template {
|
||||
task_template,
|
||||
|
@ -136,20 +141,20 @@ impl DapLocator for CargoLocator {
|
|||
|
||||
let mut test_name = None;
|
||||
if is_test {
|
||||
if let Some(package_index) = build_config
|
||||
test_name = build_config
|
||||
.args
|
||||
.iter()
|
||||
.position(|arg| arg == "-p" || arg == "--package")
|
||||
{
|
||||
test_name = build_config
|
||||
.args
|
||||
.get(package_index + 2)
|
||||
.filter(|name| !name.starts_with("--"))
|
||||
.cloned();
|
||||
}
|
||||
.rev()
|
||||
.take_while(|name| "--" != name.as_str())
|
||||
.find(|name| !name.starts_with("-"))
|
||||
.cloned();
|
||||
}
|
||||
let executable = {
|
||||
if let Some(ref name) = test_name {
|
||||
if let Some(ref name) = test_name.as_ref().and_then(|name| {
|
||||
name.strip_prefix('$')
|
||||
.map(|name| build_config.env.get(name))
|
||||
.unwrap_or(Some(name))
|
||||
}) {
|
||||
find_best_executable(&executables, &name).await
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -663,7 +663,9 @@ impl LspCommand for GetLspRunnables {
|
|||
// We cannot escape all shell arguments unconditionally, as we use this for ssh commands, which may involve paths starting with `~`.
|
||||
// That bit is not auto-expanded when using single quotes.
|
||||
// Escape extra cargo args unconditionally as those are unlikely to contain `~`.
|
||||
.map(|extra_arg| format!("'{extra_arg}'")),
|
||||
.flat_map(|extra_arg| {
|
||||
shlex::try_quote(&extra_arg).ok().map(|s| s.to_string())
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue