mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 15:42:57 +01:00
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.
This commit is contained in:
parent
65e2e8052e
commit
aae52a80ab
@ -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 })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user