rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.2k stars 1.59k forks source link

test lens is confused by test_case or rstest, because they convert functions to modules #10016

Open bcully opened 3 years ago

bcully commented 3 years ago

I am working on a project that uses test_case and rstest to parameterize tests over a range of test cases. They both appear to work by converting their test functions into modules, i.e.,

#[test_case(true; "yep")]
#[test_case(false; "nope")]
#[test]
fn test_it(really: bool) {}

would generate the tests

mymod::test_it::yep
mymod::test_it::nope

But because the rust-analyzer test lens thinks that this function is a function and not a module, it passes --exact to the cargo test invocation, which causes the test runner to run 0 tests.

I'd love it if rust_analyzer could figure out that after macro expansion there was a module here instead of a function, but failing that it would be great if there were a way to turn off --exact by hand.

Thanks!

lnicola commented 3 years ago

Does anything change if you enable attribute proc macros (rust-analyzer.experimental.procAttrMacros)?

bcully commented 3 years ago

No, it still passes --exact

RXminuS commented 2 years ago

This was actually working for me suddenly but now not anymore. https://github.com/rust-analyzer/rust-analyzer/issues/10744 even shows it working.

merc1031 commented 4 months ago

I am also recently seeing this issue. It was working sometime in the last 30 days with rstest, but now doesnt show the test lens

image

rust-analyzer: v0.3.1992 rstest: 0.21.0 (and 0.18.x) vscode settings:

    "rust-analyzer.procMacro.attributes.enable": true,
    "rust-analyzer.procMacro.enable": true
Veykril commented 4 months ago

This works fine for me on the latest nightly release image

Does happen in a clean project for you?