From e5e3e9ac8c0c823f214e6905da29da511b8be89e Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Thu, 3 Apr 2025 16:56:28 +0200 Subject: [PATCH] rust: Improve runnable detection for test modules (#28024) Closes #28002 This PR updates the `runnabless.scm` for Rust to improve detection of test modules with non-standard names. Instead of matching on the module name, we now check for the `#[cfg(test)]`-attribute above test modules. This allows for generic matching whilst not regressing the previous behaviour. | `main` | main | | --- | --- | | This PR | PR | Release Notes: - Improved runnable detection for test modules in Rust. --- crates/languages/src/rust/runnables.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/languages/src/rust/runnables.scm b/crates/languages/src/rust/runnables.scm index 43e0b078e2..7c15716144 100644 --- a/crates/languages/src/rust/runnables.scm +++ b/crates/languages/src/rust/runnables.scm @@ -1,8 +1,18 @@ ; Rust mod test ( + (attribute_item (attribute + ( + (identifier) @_attribute) + arguments: ( + (token_tree (identifier) @_test) + (#eq? @_test "test") + ) + ) + (#eq? @_attribute "cfg") + ) + . (mod_item name: (_) @run - (#eq? @run "tests") ) (#set! tag rust-mod-test) )