Skip to content

Commit

Permalink
test: update dependency syn
Browse files Browse the repository at this point in the history
  • Loading branch information
nurmohammed840 committed Oct 12, 2024
1 parent 2e96eba commit 46f17cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tokio-test/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
proc-macro = true

[dependencies]
syn = { version = "*", features = ["full"] }
syn = { version = "2", features = ["full"] }
quote2 = "0.9"
18 changes: 5 additions & 13 deletions tokio-test/macros/src/expend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use quote2::{proc_macro2::TokenStream, quote, utils::quote_rep, Quote, ToTokens}
use syn::{
parse::{Parse, ParseStream, Parser},
punctuated::Punctuated,
Attribute, Lit, Meta, MetaNameValue, Signature, Token, Visibility,
Attribute, Meta, MetaNameValue, Signature, Token, Visibility,
};

type AttributeArgs = Punctuated<Meta, Token![,]>;
Expand Down Expand Up @@ -34,10 +34,10 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
let has_miri_cfg = metadata.iter().any(|meta| meta.path().is_ident("miri"));
let id_multi_thread = metadata.iter().any(|meta| match meta {
Meta::NameValue(meta) if meta.path.is_ident("flavor") => {
match parse_string(&meta.lit, "flavor").as_str() {
match meta.value.to_token_stream().to_string().as_str() {
"multi_thread" => true,
"current_thread" => false,
_ => panic!("unknown `flavor`, expected: multi_thread | current_thread"),
val => panic!("unknown `flavor = {val}`, expected: multi_thread | current_thread"),
}
}
_ => false,
Expand All @@ -48,10 +48,10 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
return;
}
}
if let Meta::NameValue(MetaNameValue { path, lit, .. }) = &meta {
if let Meta::NameValue(MetaNameValue { path, value, .. }) = &meta {
for key in ["worker_threads", "start_paused"] {
if path.is_ident(key) {
quote!(t, { .#path(#lit) });
quote!(t, { .#path(#value) });
return;
}
}
Expand Down Expand Up @@ -119,11 +119,3 @@ pub fn tokio_test(args: TokenStream, item_fn: ItemFn) -> TokenStream {
});
out
}

fn parse_string(int: &Lit, field: &str) -> String {
match int {
Lit::Str(s) => s.value(),
Lit::Verbatim(s) => s.to_string(),
_ => panic!("Failed to parse value of `{}` as string.", field),
}
}

0 comments on commit 46f17cc

Please sign in to comment.