Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run individual parameterized tests - e.g. with test_case #6687

Closed
sazzer opened this issue Dec 1, 2020 · 1 comment · Fixed by #9128
Closed

Unable to run individual parameterized tests - e.g. with test_case #6687

sazzer opened this issue Dec 1, 2020 · 1 comment · Fixed by #9128
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@sazzer
Copy link

sazzer commented Dec 1, 2020

Using crates for parameterized testing doesn't allow me to run the individual tests using the "Run Test" action. I can run the entire set of tests in the module, but not a single method.

The reason for this is because the tests are run with --exact but the name provided is not the exact test name, since the exact test name is ultimately generated.

For example, given the test:

    #[test_case("", ParseUserIDError::Malformed ; "Blank")]
    fn failed_parse(input: &str, expected: ParseUserIDError) {
        let parsed: Result<UserID, ParseUserIDError> = input.parse();
        let_assert!(Err(err) = parsed);
        check!(err == expected);
    }

Running this will execute:

cargo test --package universe --lib -- users::model::user_id::tests::failed_parse --exact --nocapture <

Whilst the exact test name is users::model::user_id::tests::failed_parse::blank (And an additional test function for each occurrence of test_case)

If I use the "Run Test" action on the module as a whole, it executes without the --exact flag and thus works.

@bjorn3
Copy link
Member

bjorn3 commented Dec 1, 2020

Without --exact if there would be a test called foo and foobar, trying to run foo would run both. It would be better to keep passing --exact, but implement expansion of attribute proc macros.

@lnicola lnicola added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Dec 20, 2020
bors bot added a commit that referenced this issue Jun 3, 2021
9128: feat: expand procedural attribute macros r=jonas-schievink a=jonas-schievink

This adds experimental support for attribute macros. They can be enabled by setting `rust-analyzer.experimental.procAttrMacros` to `true`.

Known issues:
* Tokens aren't remapped, presumably because we edit the input syntax tree (this causes IDE features to not work inside items with attribute macros on them)
* Macro errors aren't reported correctly

Closes #8971
Fixes #8964 / la10736/rstest#120
Fixes #2984
Fixes #5412
Fixes #6029
Fixes #6687

#6740 is still not fixed – we now expand `#[proc_macro_hack]`, but fail to expand the resulting `proc_macro_call!()` macro.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
@bors bors bot closed this as completed in 1415367 Jun 3, 2021
@bors bors bot closed this as completed in #9128 Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants