Skip to content

Commit 65e9be3

Browse files
committed
Allow shell runnables to define test commands with substitution in arguments
1 parent b1fc71f commit 65e9be3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

crates/project-model/src/project_json.rs

+1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ pub struct ShellRunnableArgs {
272272
pub enum ShellRunnableKind {
273273
Check,
274274
Run,
275+
TestOne,
275276
}
276277

277278
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Deserialize)]

crates/rust-analyzer/src/target_spec.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,24 @@ impl ProjectJsonTargetSpec {
7878

7979
None
8080
}
81-
RunnableKind::Test { .. } => None,
81+
RunnableKind::Test { test_id, .. } => {
82+
for runnable in &self.shell_runnables {
83+
if matches!(runnable.kind, ShellRunnableKind::TestOne) {
84+
let mut runnable = runnable.clone();
85+
86+
let replaced_args: Vec<_> = runnable
87+
.args
88+
.iter()
89+
.map(|arg| arg.replace("$$TEST_NAME$$", &test_id.to_string()))
90+
.collect();
91+
runnable.args = replaced_args;
92+
93+
return Some(runnable);
94+
}
95+
}
96+
97+
None
98+
}
8299
RunnableKind::TestMod { .. } => None,
83100
RunnableKind::Bench { .. } => None,
84101
RunnableKind::DocTest { .. } => None,

0 commit comments

Comments
 (0)