use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{parse_macro_input, ItemFn, ReturnType};
#[proc_macro_attribute]
pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
test_impl(attr, item)
}
fn test_impl(attr: TokenStream, item: TokenStream) -> TokenStream {
let args = TokenStream2::from(attr);
let item = parse_macro_input!(item as ItemFn);
let attrs = &item.attrs;
let async_ = &item.sig.asyncness;
let await_ = if async_.is_some() {
quote! {.await}
} else {
quote! {}
};
let inputs = &item.sig.inputs;
let body = &item.block;
let test_name = &item.sig.ident;
let ret = match &item.sig.output {
ReturnType::Default => quote! {},
ReturnType::Type(_, type_) => quote! {-> #type_},
};
quote! {
#[::mz_ore::test(
#args
)]
#(#attrs)*
#async_ fn #test_name() #ret {
#async_ fn test_impl(#inputs) #ret {
#body
}
let dyncfgs = [
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_inline_writes_single_max_bytes", ::mz_dyncfg::ConfigVal::Usize(0));
x.add_dynamic("persist_inline_writes_total_max_bytes", ::mz_dyncfg::ConfigVal::Usize(0));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_inline_writes_single_max_bytes", ::mz_dyncfg::ConfigVal::Usize(4 * 1024));
x.add_dynamic("persist_inline_writes_total_max_bytes", ::mz_dyncfg::ConfigVal::Usize(1024 * 1024));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_inline_writes_single_max_bytes", ::mz_dyncfg::ConfigVal::Usize(4 * 1024));
x.add_dynamic("persist_inline_writes_total_max_bytes", ::mz_dyncfg::ConfigVal::Usize(0));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_record_compactions", ::mz_dyncfg::ConfigVal::Bool(true));
x.add_dynamic("persist_claim_unclaimed_compactions", ::mz_dyncfg::ConfigVal::Bool(true));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_record_schema_id", ::mz_dyncfg::ConfigVal::Bool(true));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_batch_columnar_format", ::mz_dyncfg::ConfigVal::String("both_v2".into()));
x.add_dynamic("persist_batch_columnar_format_percent", ::mz_dyncfg::ConfigVal::Usize(100));
x.add_dynamic("persist_part_decode_format", ::mz_dyncfg::ConfigVal::String("arrow".into()));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_batch_columnar_format", ::mz_dyncfg::ConfigVal::String("both_v2".into()));
x.add_dynamic("persist_batch_columnar_format_percent", ::mz_dyncfg::ConfigVal::Usize(100));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_batch_columnar_format", ::mz_dyncfg::ConfigVal::String("both_v2".into()));
x.add_dynamic("persist_batch_columnar_format_percent", ::mz_dyncfg::ConfigVal::Usize(100));
x.add_dynamic("persist_batch_structured_key_lower_len", ::mz_dyncfg::ConfigVal::Usize(256));
x.add_dynamic("persist_batch_structured_order", ::mz_dyncfg::ConfigVal::Bool(true));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_encoding_enable_dictionary", ::mz_dyncfg::ConfigVal::Bool(true));
x
},
{
let mut x = ::mz_dyncfg::ConfigUpdates::default();
x.add_dynamic("persist_batch_max_run_len", ::mz_dyncfg::ConfigVal::Usize(4));
x
},
];
for (idx, dyncfgs) in dyncfgs.into_iter().enumerate() {
let debug = dyncfgs.updates.iter().map(|(name, val)| {
format!(" {}={:?}", name, val.val.clone().unwrap())
}).collect::<String>();
eprintln!("mz_persist_proc::test {}{}", idx, debug);
test_impl(dyncfgs)#await_
}
}
}
.into()
}