test: Add proc macro DSL for declarative tests.

This commit is contained in:
2026-03-13 21:58:17 -04:00
parent cb7911e5c9
commit 522b9f2894
4 changed files with 1103 additions and 0 deletions

View 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(),
}
}