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

Actually properly support async #82

Merged
merged 11 commits into from
Dec 14, 2022
Prev Previous commit
Next Next commit
Fix the "with return" case
  • Loading branch information
palfrey committed Dec 11, 2022
commit 9f1c09a2693ad46d1e42a8bc6e9cd30a3148d76f
12 changes: 10 additions & 2 deletions serial_test_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,15 @@ where
match asyncness {
Some(_) => {
let fnname = format_ident!("{}_async_{}_core_with_return", prefix, kind);
let temp_fn = format_ident!("{}_internal", name);
quote! {
async fn #temp_fn () -> #ret
#block

#(#attrs)
*
#vis async fn #name () -> #ret {
serial_test::#fnname(#(#args ),*, || async #block ).await;
serial_test::#fnname(#(#args ),*, #temp_fn()).await
}
}
}
Expand All @@ -435,11 +439,15 @@ where
match asyncness {
Some(_) => {
let fnname = format_ident!("{}_async_{}_core", prefix, kind);
let temp_fn = format_ident!("{}_internal", name);
quote! {
async fn #temp_fn ()
#block

#(#attrs)
*
#vis async fn #name () {
serial_test::#fnname(#(#args ),*, || async #block ).await;
serial_test::#fnname(#(#args ),*, #temp_fn()).await;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions serial_test_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,8 @@ mod tests {
#[serial]
async fn async_attribute_works() {
}
#[serial]
async fn async_attribute_works_with_return() -> Result<(), ()> {
Ok(())
}
}