use proc_macro::TokenStream;
use quote::quote;
use syn::{ItemFn, parse_macro_input};

#[proc_macro_attribute]
pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
    let input_fn = parse_macro_input!(item as ItemFn);
    let attrs = &input_fn.attrs;
    let vis = &input_fn.vis;
    let sig = &input_fn.sig;
    let block = &input_fn.block;

    let expanded = quote! {
        // #[cfg(not(feature = "shuttle"))]
        #[test_log::test(tokio::test)]
        #[test_log(default_log_filter = "warn")]
        #(#attrs)*
        #vis #sig #block
    };

    TokenStream::from(expanded)
}

#[proc_macro_attribute]
pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
    let input_fn = parse_macro_input!(item as ItemFn);
    let attrs = &input_fn.attrs;
    let vis = &input_fn.vis;
    let sig = &input_fn.sig;
    let block = &input_fn.block;

    let expanded = quote! {
        #[test_log::test]
        #[test_log(default_log_filter = "warn")]
        #(#attrs)*
        #vis #sig #block
    };

    TokenStream::from(expanded)
}
