la10736 / rstest

Fixture-based test framework for Rust
Apache License 2.0
1.21k stars 43 forks source link

Allow `clippy::too_many_arguments` #226

Closed dariocurr closed 11 months ago

dariocurr commented 11 months ago

Hi, this is Dario from hiop.

I have an async fn test function that uses 8 parameters. I cannot #[allow(clippy::too_many_arguments)] probably because the Error originated from a macro called here.

Is there any way to allow this without changing other macro configurations?

If a fix is needed, I am more than happy to contribute to this awesome project.

la10736 commented 11 months ago

Hi Dario, can you post a simple example that's expose the issue?

Anyway I guess that to annotate the test module by #[allow(clippy::too_many_arguments)] should work... let me know

Il giorno mer 13 dic 2023 alle ore 11:01 Dario Curreri < @.***> ha scritto:

Hi, this is Dario from hiop.

I have an async fn test function that uses 8 parameters. I cannot #[allow(clippy::too_many_arguments)] probably because the Error originated from a macro called here.

Is there any way to allow this without changing other macro configurations?

If a fix is needed, I am more than happy to contribute to this awesome project.

— Reply to this email directly, view it on GitHub https://github.com/la10736/rstest/issues/226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5Y34LGZGOQLU6Y7R4LHBLYJF4IHAVCNFSM6AAAAABAS337EOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZTSMZVHA3DANA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dariocurr commented 11 months ago

Put it at module level solved the issue. By the way I provide you the example:

#[allow(clippy::too_many_arguments)] // this works
mod tests {
    use rstest::rstest;

    #[allow(clippy::too_many_arguments)] // this does not work
    #[rstest]
    #[case(1, 2, 3, 4, 5, 6, 7, 8)]
    fn test_fn(
        #[case] _a: u8,
        #[case] _b: u8,
        #[case] _c: u8,
        #[case] _d: u8,
        #[case] _e: u8,
        #[case] _f: u8,
        #[case] _g: u8,
        #[case] _h: u8,
    ) {
    }
}
la10736 commented 11 months ago

Ok... According to https://docs.rs/rstest/latest/rstest/attr.rstest.html#use-specific-case-attributes you should move the annotation before the function instead of put it before #[rstest].

dariocurr commented 11 months ago

Sorry, I should have mentioned before that I tried it already. As you can check:

//#[allow(clippy::too_many_arguments)] // this works
mod tests {
    use rstest::rstest;

    #[allow(clippy::too_many_arguments)] // this does not work
    #[rstest]
    #[allow(clippy::too_many_arguments)] // this does not work
    #[case(1, 2, 3, 4, 5, 6, 7, 8)]
    #[allow(clippy::too_many_arguments)] // this does not work
    fn test_fn(
        #[case] _a: u8,
        #[case] _b: u8,
        #[case] _c: u8,
        #[case] _d: u8,
        #[case] _e: u8,
        #[case] _f: u8,
        #[case] _g: u8,
        #[case] _h: u8,
    ) {
    }
}
la10736 commented 11 months ago

Wired!!!! On my side it works like a charm in all cases

damico@miklap:~/dev_random/rstest_226$ cargo test && cat src/main.rs && cargo clippy && rustup show | tail
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/main.rs (target/debug/deps/rstest_226-a0447c32f017b59d)

running 1 test
test tests::test_fn::case_1 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

fn main() {
    println!("Hello, world!");
}

mod tests {
    use rstest::rstest;

    #[allow(clippy::too_many_arguments)] // this does not work
    #[rstest]
    #[allow(clippy::too_many_arguments)] // this does not work
    #[case(1, 2, 3, 4, 5, 6, 7, 8)]
    #[allow(clippy::too_many_arguments)] // this does not work
    fn test_fn(
        #[case] _a: u8,
        #[case] _b: u8,
        #[case] _c: u8,
        #[case] _d: u8,
        #[case] _e: u8,
        #[case] _f: u8,
        #[case] _g: u8,
        #[case] _h: u8,
    ) {
    }
}
    Checking rstest_226 v0.1.0 (/home/mdamico/dev_random/rstest_226)
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.74.1 (a28077b28 2023-12-04)
dariocurr commented 11 months ago

Then I guess it's a rust-analyzer bug

image

Moreover, If i run cargo clippy -- --deny warnings, everything works fine