Skip to main content

toasty_driver_integration_suite_macros/
lib.rs

1extern crate proc_macro;
2
3mod driver_test;
4mod id_rewriter;
5mod parse;
6mod scenario;
7mod test_registry;
8mod test_variants;
9
10use proc_macro::TokenStream;
11
12#[proc_macro_attribute]
13pub fn driver_test(attr: TokenStream, item: TokenStream) -> TokenStream {
14    driver_test::expand(attr, item)
15}
16
17#[proc_macro]
18pub fn generate_test_registry(input: TokenStream) -> TokenStream {
19    test_registry::expand(input)
20}
21
22#[proc_macro]
23pub fn generate_driver_test_variants(input: TokenStream) -> TokenStream {
24    test_variants::expand(input)
25}
26
27#[proc_macro]
28pub fn scenario(input: TokenStream) -> TokenStream {
29    scenario::expand(input)
30}
31
32/// Expression macro that evaluates to true or false based on the current driver test expansion.
33/// This is rewritten by the #[driver_test] attribute macro based on the expansion context.
34#[proc_macro]
35pub fn driver_test_cfg(_input: TokenStream) -> TokenStream {
36    // This should never be called directly - it should be rewritten by #[driver_test]
37    // If it is called, emit a helpful error
38    let error = syn::Error::new(
39        proc_macro2::Span::call_site(),
40        "driver_test_cfg! can only be used inside a #[driver_test] function",
41    );
42    error.to_compile_error().into()
43}