From aae52a80ab2df410538e62f8bcc0bccc5d9dcd0f Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Wed, 8 Apr 2020 16:48:10 +0200 Subject: [PATCH] Forward actix_rt::test arguments to test function. Previously, ```rust async fn foo(_a: u32) {} ``` would compile to ```rust fn foo() {/* something */} ``` This patches changes this behaviour to ```rust fn foo(_a: u32) {/* something */} ``` by simply forwarding the input arguments. This allows any test fixture library (e.g. `rstest`, cfr. https://github.com/la10736/rstest/issues/85) to integrate with actix::test. --- actix-macros/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actix-macros/src/lib.rs b/actix-macros/src/lib.rs index b6a57b9d..ffd81475 100644 --- a/actix-macros/src/lib.rs +++ b/actix-macros/src/lib.rs @@ -58,6 +58,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(item as syn::ItemFn); let ret = &input.sig.output; + let inputs = &input.sig.inputs; let name = &input.sig.ident; let body = &input.block; let attrs = &input.attrs; @@ -81,7 +82,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream { let result = if has_test_attr { quote! { #(#attrs)* - fn #name() #ret { + fn #name(#inputs) #ret { actix_rt::System::new("test") .block_on(async { #body }) } @@ -90,7 +91,7 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream { quote! { #[test] #(#attrs)* - fn #name() #ret { + fn #name(#inputs) #ret { actix_rt::System::new("test") .block_on(async { #body }) }