Unnamed repository; edit this file 'description' to name the repository.
feat: add ${exact} and ${include_ignored} placeholders to overrideCommand
Stanley Horwood 6 weeks ago
parent 129f616 · commit 7492b18
-rw-r--r--crates/rust-analyzer/src/config.rs38
-rw-r--r--crates/rust-analyzer/src/target_spec.rs19
-rw-r--r--docs/book/src/configuration_generated.md38
-rw-r--r--editors/code/package.json6
4 files changed, 77 insertions, 24 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 74d498368c..3a88a8fe84 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -960,18 +960,30 @@ config_data! {
/// Override the command used for bench runnables.
/// The first element of the array should be the program to execute (for example, `cargo`).
///
- /// Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
- /// replace the package name, target option (such as `--bin` or `--example`), the target name and
- /// the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+ /// Use the placeholders:
+ /// - `${package}`: package name.
+ /// - `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+ /// - `${target}`: target name (empty for `--lib`).
+ /// - `${test_name}`: the test path filter, e.g. `module::bench_func`.
+ /// - `${exact}`: `--exact` for single benchmarks, empty for modules.
+ /// - `${include_ignored}`: always empty for benchmarks.
+ /// - `${executable_args}`: all of the above binary args bundled together
+ /// (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
runnables_bench_overrideCommand: Option<Vec<String>> = None,
/// Command to be executed instead of 'cargo' for runnables.
runnables_command: Option<String> = None,
- /// Override the command used for bench runnables.
+ /// Override the command used for doc-test runnables.
/// The first element of the array should be the program to execute (for example, `cargo`).
///
- /// Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
- /// replace the package name, target option (such as `--bin` or `--example`), the target name and
- /// the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+ /// Use the placeholders:
+ /// - `${package}`: package name.
+ /// - `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+ /// - `${target}`: target name (empty for `--lib`).
+ /// - `${test_name}`: the test path filter, e.g. `module::func`.
+ /// - `${exact}`: always empty for doc-tests.
+ /// - `${include_ignored}`: always empty for doc-tests.
+ /// - `${executable_args}`: all of the above binary args bundled together
+ /// (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
runnables_doctest_overrideCommand: Option<Vec<String>> = None,
/// Additional arguments to be passed to cargo for runnables such as
/// tests or binaries. For example, it may be `--release`.
@@ -989,9 +1001,15 @@ config_data! {
/// Override the command used for test runnables.
/// The first element of the array should be the program to execute (for example, `cargo`).
///
- /// Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
- /// replace the package name, target option (such as `--bin` or `--example`), the target name and
- /// the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+ /// Available placeholders:
+ /// - `${package}`: package name.
+ /// - `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+ /// - `${target}`: target name (empty for `--lib`).
+ /// - `${test_name}`: the test path filter, e.g. `module::test_func`.
+ /// - `${exact}`: `--exact` for single tests, empty for modules.
+ /// - `${include_ignored}`: `--include-ignored` for single tests, empty otherwise.
+ /// - `${executable_args}`: all of the above binary args bundled together
+ /// (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
runnables_test_overrideCommand: Option<Vec<String>> = None,
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
diff --git a/crates/rust-analyzer/src/target_spec.rs b/crates/rust-analyzer/src/target_spec.rs
index c1d52e4c9b..beb523e6bd 100644
--- a/crates/rust-analyzer/src/target_spec.rs
+++ b/crates/rust-analyzer/src/target_spec.rs
@@ -230,6 +230,21 @@ impl CargoTargetSpec {
};
let test_name = test_name.unwrap_or_default();
+ let exact = match kind {
+ RunnableKind::Test { test_id } | RunnableKind::Bench { test_id } => match test_id {
+ TestId::Path(_) => "",
+ TestId::Name(_) => "--exact",
+ },
+ _ => "",
+ };
+ let include_ignored = match kind {
+ RunnableKind::Test { test_id } => match test_id {
+ TestId::Path(_) => "",
+ TestId::Name(_) => "--include-ignored",
+ },
+ _ => "",
+ };
+
let target_arg = |kind| match kind {
TargetKind::Bin => "--bin",
TargetKind::Test => "--test",
@@ -249,7 +264,9 @@ impl CargoTargetSpec {
.replace("${package}", &spec.package)
.replace("${target_arg}", target_arg(spec.target_kind))
.replace("${target}", target(spec.target_kind, &spec.target))
- .replace("${test_name}", &test_name),
+ .replace("${test_name}", &test_name)
+ .replace("${exact}", exact)
+ .replace("${include_ignored}", include_ignored),
_ => arg,
};
diff --git a/docs/book/src/configuration_generated.md b/docs/book/src/configuration_generated.md
index 548c5fb093..da37fc1582 100644
--- a/docs/book/src/configuration_generated.md
+++ b/docs/book/src/configuration_generated.md
@@ -1404,9 +1404,15 @@ Default: `null`
Override the command used for bench runnables.
The first element of the array should be the program to execute (for example, `cargo`).
-Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
-replace the package name, target option (such as `--bin` or `--example`), the target name and
-the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+Use the placeholders:
+- `${package}`: package name.
+- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+- `${target}`: target name (empty for `--lib`).
+- `${test_name}`: the test path filter, e.g. `module::bench_func`.
+- `${exact}`: `--exact` for single benchmarks, empty for modules.
+- `${include_ignored}`: always empty for benchmarks.
+- `${executable_args}`: all of the above binary args bundled together
+ (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
## rust-analyzer.runnables.command {#runnables.command}
@@ -1420,12 +1426,18 @@ Command to be executed instead of 'cargo' for runnables.
Default: `null`
-Override the command used for bench runnables.
+Override the command used for doc-test runnables.
The first element of the array should be the program to execute (for example, `cargo`).
-Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
-replace the package name, target option (such as `--bin` or `--example`), the target name and
-the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+Use the placeholders:
+- `${package}`: package name.
+- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+- `${target}`: target name (empty for `--lib`).
+- `${test_name}`: the test path filter, e.g. `module::func`.
+- `${exact}`: always empty for doc-tests.
+- `${include_ignored}`: always empty for doc-tests.
+- `${executable_args}`: all of the above binary args bundled together
+ (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
## rust-analyzer.runnables.extraArgs {#runnables.extraArgs}
@@ -1468,9 +1480,15 @@ Default: `null`
Override the command used for test runnables.
The first element of the array should be the program to execute (for example, `cargo`).
-Use the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically
-replace the package name, target option (such as `--bin` or `--example`), the target name and
-the arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
+Available placeholders:
+- `${package}`: package name.
+- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.
+- `${target}`: target name (empty for `--lib`).
+- `${test_name}`: the test path filter, e.g. `module::test_func`.
+- `${exact}`: `--exact` for single tests, empty for modules.
+- `${include_ignored}`: `--include-ignored` for single tests, empty otherwise.
+- `${executable_args}`: all of the above binary args bundled together
+ (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
## rust-analyzer.rustc.source {#rustc.source}
diff --git a/editors/code/package.json b/editors/code/package.json
index 8c99b30ce9..29cbc8bd4f 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -2909,7 +2909,7 @@
"title": "Runnables",
"properties": {
"rust-analyzer.runnables.bench.overrideCommand": {
- "markdownDescription": "Override the command used for bench runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nUse the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically\nreplace the package name, target option (such as `--bin` or `--example`), the target name and\nthe arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
+ "markdownDescription": "Override the command used for bench runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nUse the placeholders:\n- `${package}`: package name.\n- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.\n- `${target}`: target name (empty for `--lib`).\n- `${test_name}`: the test path filter, e.g. `module::bench_func`.\n- `${exact}`: `--exact` for single benchmarks, empty for modules.\n- `${include_ignored}`: always empty for benchmarks.\n- `${executable_args}`: all of the above binary args bundled together\n (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
"default": null,
"type": [
"null",
@@ -2938,7 +2938,7 @@
"title": "Runnables",
"properties": {
"rust-analyzer.runnables.doctest.overrideCommand": {
- "markdownDescription": "Override the command used for bench runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nUse the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically\nreplace the package name, target option (such as `--bin` or `--example`), the target name and\nthe arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
+ "markdownDescription": "Override the command used for doc-test runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nUse the placeholders:\n- `${package}`: package name.\n- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.\n- `${target}`: target name (empty for `--lib`).\n- `${test_name}`: the test path filter, e.g. `module::func`.\n- `${exact}`: always empty for doc-tests.\n- `${include_ignored}`: always empty for doc-tests.\n- `${executable_args}`: all of the above binary args bundled together\n (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
"default": null,
"type": [
"null",
@@ -2992,7 +2992,7 @@
"title": "Runnables",
"properties": {
"rust-analyzer.runnables.test.overrideCommand": {
- "markdownDescription": "Override the command used for test runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nUse the placeholders `${package}`, `${target_arg}`, `${target}`, `${executable_args}` to dynamically\nreplace the package name, target option (such as `--bin` or `--example`), the target name and\nthe arguments passed to test binary args (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
+ "markdownDescription": "Override the command used for test runnables.\nThe first element of the array should be the program to execute (for example, `cargo`).\n\nAvailable placeholders:\n- `${package}`: package name.\n- `${target_arg}`: target option such as `--bin`, `--test`, `--lib`, etc.\n- `${target}`: target name (empty for `--lib`).\n- `${test_name}`: the test path filter, e.g. `module::test_func`.\n- `${exact}`: `--exact` for single tests, empty for modules.\n- `${include_ignored}`: `--include-ignored` for single tests, empty otherwise.\n- `${executable_args}`: all of the above binary args bundled together\n (includes `rust-analyzer.runnables.extraTestBinaryArgs`).",
"default": null,
"type": [
"null",