Skip to content

Commit

Permalink
Append generated test macro so next test macros are aware of it
Browse files Browse the repository at this point in the history
This way test macros following `#[rstest]` can decide whether or not to
generate test macro to avoid duplicate test runs.

It is an attempt to improve capabilities among test macros. Currently,
following test from [googletest](https://github.com/google/googletest-rust/blob/21f2948684847922a416252b8118e3eada8e29d6/integration_tests/src/google_test_with_rstest.rs#L52-L57)(`main` branch at 2025-01-16) will run twice.

```rust
#[rstest]
#[case(1)]
#[gtest]
fn paramterised_test_should_work_with_rstest_first(#[case] value: u32) -> Result<()> {
    verify_that!(value, eq(value))
}
```

See: tokio-rs/tokio#6497, d-e-s-o/test-log#46, frondeus/test-case#143, kezhuw/stuck#53.
Refs: rust-lang/rust#67839, rust-lang/rust#82419.
  • Loading branch information
kezhuw committed Jan 16, 2025
1 parent 154d0b0 commit 28e20ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rstest_macros/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ fn single_test_case(
let lifetimes = generics.lifetimes();

quote! {
#test_attr
#(#attrs)*
#test_attr
#asyncness fn #name<#(#lifetimes,)*>(#(#ignored_args,)*) #output {
#test_impl
#inject
Expand Down

0 comments on commit 28e20ea

Please sign in to comment.