MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / expand_wrapper

Function expand_wrapper

src/ore-proc/src/test.rs:72–106  ·  view source on GitHub ↗

Emit code for a wrapper function around a test function.

(inner_test: &TokenStream2, wrappee: &ItemFn)

Source from the content-addressed store, hash-verified

70
71/// Emit code for a wrapper function around a test function.
72fn expand_wrapper(inner_test: &TokenStream2, wrappee: &ItemFn) -> TokenStream {
73 let attrs = &wrappee.attrs;
74 let async_ = &wrappee.sig.asyncness;
75 let await_ = if async_.is_some() {
76 quote! {.await}
77 } else {
78 quote! {}
79 };
80 let body = &wrappee.block;
81 let test_name = &wrappee.sig.ident;
82
83 // Note that Rust does not allow us to have a test function with
84 // #[should_panic] that has a non-unit return value.
85 let ret = match &wrappee.sig.output {
86 ReturnType::Default => quote! {},
87 ReturnType::Type(_, type_) => quote! {-> #type_},
88 };
89
90 let logging_init = expand_logging_init();
91
92 let result = quote! {
93 #[#inner_test]
94 #(#attrs)*
95 #async_ fn #test_name() #ret {
96 #async_ fn test_impl() #ret {
97 #body
98 }
99
100 #logging_init
101
102 test_impl()#await_
103 }
104 };
105 result.into()
106}

Callers 1

test_implFunction · 0.85

Calls 2

expand_logging_initFunction · 0.85
is_someMethod · 0.80

Tested by

no test coverage detected