test: Add proc macro DSL for declarative tests.
This commit is contained in:
25
crates/pikl-test-macros/src/lib.rs
Normal file
25
crates/pikl-test-macros/src/lib.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
extern crate proc_macro;
|
||||
|
||||
mod codegen;
|
||||
mod parse;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
/// Test DSL for pikl-menu. Generates individual test
|
||||
/// functions from a concise block-based syntax.
|
||||
///
|
||||
/// Supported test kinds:
|
||||
/// - `headless`: integration tests that spawn the pikl binary
|
||||
/// - `filter`: unit tests for fuzzy filter matching
|
||||
/// - `nav`: unit tests for viewport/cursor math
|
||||
/// - `menu`: async unit tests for the menu state machine
|
||||
///
|
||||
/// See the project's test files for usage examples.
|
||||
#[proc_macro]
|
||||
pub fn pikl_tests(input: TokenStream) -> TokenStream {
|
||||
let parsed = syn::parse_macro_input!(input as parse::PiklTests);
|
||||
match codegen::generate(&parsed) {
|
||||
Ok(tokens) => tokens.into(),
|
||||
Err(err) => err.to_compile_error().into(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user