Skip to content

Commit

Permalink
Remove extra braces around generated serial code to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
palfrey committed May 20, 2021
1 parent c93e1f8 commit bff5004
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions serial_test_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,14 @@ fn serial_core(
#(#attrs)
*
async fn #name () -> #ret {
serial_test::async_serial_core_with_return(#key, || async {
#block
}).await;
serial_test::async_serial_core_with_return(#key, || async #block ).await;
}
},
None => quote! {
#(#attrs)
*
fn #name () -> #ret {
serial_test::serial_core_with_return(#key, || {
#block
})
serial_test::serial_core_with_return(#key, || #block )
}
},
}
Expand All @@ -124,18 +120,14 @@ fn serial_core(
#(#attrs)
*
async fn #name () {
serial_test::async_serial_core(#key, || async {
#block
}).await;
serial_test::async_serial_core(#key, || async #block ).await;
}
},
None => quote! {
#(#attrs)
*
fn #name () {
serial_test::serial_core(#key, || {
#block
});
serial_test::serial_core(#key, || #block );
}
},
}
Expand All @@ -153,9 +145,7 @@ fn test_serial() {
let compare = quote! {
#[test]
fn foo () {
serial_test::serial_core("", || {
{}
});
serial_test::serial_core("", || {} );
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
Expand All @@ -177,9 +167,7 @@ fn test_stripped_attributes() {
#[test]
#[something_else]
fn foo () {
serial_test::serial_core("", || {
{}
});
serial_test::serial_core("", || {} );
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
Expand All @@ -196,9 +184,7 @@ fn test_serial_async() {
let compare = quote! {
#[tokio::test]
async fn foo () {
serial_test::async_serial_core("", || async {
{}
}).await;
serial_test::async_serial_core("", || async {} ).await;
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
Expand All @@ -215,9 +201,7 @@ fn test_serial_async_return() {
let compare = quote! {
#[tokio::test]
async fn foo () -> Result<(), ()> {
serial_test::async_serial_core_with_return("", || async {
{ Ok(()) }
}).await;
serial_test::async_serial_core_with_return("", || async { Ok(()) } ).await;
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
Expand Down

0 comments on commit bff5004

Please sign in to comment.