mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-23 08:48:08 +00:00
Merge 2f064dd63c into 9d58a93602
This commit is contained in:
commit
a5f0937842
2 changed files with 34 additions and 30 deletions
|
|
@ -43,12 +43,18 @@ pub enum TestId {
|
|||
Path(String),
|
||||
}
|
||||
|
||||
impl TestId {
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self {
|
||||
Self::Name(n) => n,
|
||||
Self::Path(p) => p,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TestId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
TestId::Name(name) => name.fmt(f),
|
||||
TestId::Path(path) => path.fmt(f),
|
||||
}
|
||||
f.write_str(self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,34 +73,32 @@ pub(crate) struct ProjectJsonTargetSpec {
|
|||
impl ProjectJsonTargetSpec {
|
||||
pub(crate) fn runnable_args(&self, kind: &RunnableKind) -> Option<Runnable> {
|
||||
match kind {
|
||||
RunnableKind::Bin => {
|
||||
for runnable in &self.shell_runnables {
|
||||
if matches!(runnable.kind, project_model::project_json::RunnableKind::Run) {
|
||||
return Some(runnable.clone());
|
||||
}
|
||||
}
|
||||
RunnableKind::Bin => self
|
||||
.shell_runnables
|
||||
.iter()
|
||||
.find(|r| matches!(r.kind, project_model::project_json::RunnableKind::Run))
|
||||
.cloned()
|
||||
.map(|mut runnable| {
|
||||
runnable.args.iter_mut().for_each(|arg| {
|
||||
*arg = arg.replace("{label}", &self.label);
|
||||
});
|
||||
|
||||
None
|
||||
}
|
||||
RunnableKind::Test { test_id, .. } => {
|
||||
for runnable in &self.shell_runnables {
|
||||
if matches!(runnable.kind, project_model::project_json::RunnableKind::TestOne) {
|
||||
let mut runnable = runnable.clone();
|
||||
runnable
|
||||
}),
|
||||
RunnableKind::Test { test_id, .. } => self
|
||||
.shell_runnables
|
||||
.iter()
|
||||
.find(|r| matches!(r.kind, project_model::project_json::RunnableKind::TestOne))
|
||||
.cloned()
|
||||
.map(|mut runnable| {
|
||||
runnable.args.iter_mut().for_each(|arg| {
|
||||
*arg = arg
|
||||
.replace("{label}", &self.label)
|
||||
.replace("{test_id}", test_id.as_str());
|
||||
});
|
||||
|
||||
let replaced_args: Vec<_> = runnable
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| arg.replace("{test_id}", &test_id.to_string()))
|
||||
.map(|arg| arg.replace("{label}", &self.label))
|
||||
.collect();
|
||||
runnable.args = replaced_args;
|
||||
|
||||
return Some(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
runnable
|
||||
}),
|
||||
RunnableKind::TestMod { .. } => None,
|
||||
RunnableKind::Bench { .. } => None,
|
||||
RunnableKind::DocTest { .. } => None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue