mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Upgrade tokio to 1.10 (#9575)
* Upgrade tokio to 1.10 * Fix test runner * Try fix it * Update Cargo.lock * Review feedback * ahhhh * FML * FMT * Fix tests
This commit is contained in:
@@ -22,19 +22,14 @@ use quote::quote;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
impl_test(args, item)
|
||||
}
|
||||
|
||||
fn impl_test(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let input = syn::parse_macro_input!(item as syn::ItemFn);
|
||||
let args = syn::parse_macro_input!(args as syn::AttributeArgs);
|
||||
|
||||
parse_knobs(input, args).unwrap_or_else(|e| e.to_compile_error().into())
|
||||
parse_knobs(input, args.into()).unwrap_or_else(|e| e.to_compile_error().into())
|
||||
}
|
||||
|
||||
fn parse_knobs(
|
||||
mut input: syn::ItemFn,
|
||||
args: syn::AttributeArgs,
|
||||
args: proc_macro2::TokenStream,
|
||||
) -> Result<TokenStream, syn::Error> {
|
||||
let sig = &mut input.sig;
|
||||
let body = &input.block;
|
||||
@@ -62,7 +57,7 @@ fn parse_knobs(
|
||||
|
||||
let header = {
|
||||
quote! {
|
||||
#[#crate_name::tokio::test(#(#args)*)]
|
||||
#[#crate_name::tokio::test( #args )]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -76,25 +71,15 @@ fn parse_knobs(
|
||||
#crate_name::tokio::spawn(fut).map(drop)
|
||||
})
|
||||
.into();
|
||||
let timeout_task = #crate_name::tokio::time::delay_for(
|
||||
if #crate_name::tokio::time::timeout(
|
||||
std::time::Duration::from_secs(
|
||||
std::env::var("SUBSTRATE_TEST_TIMEOUT")
|
||||
.ok()
|
||||
.and_then(|x| x.parse().ok())
|
||||
.unwrap_or(600))
|
||||
).fuse();
|
||||
let actual_test_task = async move {
|
||||
#body
|
||||
}
|
||||
.fuse();
|
||||
|
||||
#crate_name::futures::pin_mut!(timeout_task, actual_test_task);
|
||||
|
||||
#crate_name::futures::select! {
|
||||
_ = timeout_task => {
|
||||
panic!("The test took too long!");
|
||||
},
|
||||
_ = actual_test_task => {},
|
||||
.unwrap_or(600)),
|
||||
async move { #body },
|
||||
).await.is_err() {
|
||||
panic!("The test took too long!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user