We don't currently test our proc macros and it'd be nice to do so. Usually this would be done with something like https://crates.io/crates/trybuild which runs cargo and tries to compile a test input, and checks for success/failure. However we cannot use it with meson directly, plus it would drag in a lot of dependencies anyway.
Instead of compiling, we can easily just expand test input into token streams since we already split macro implementation into separate functions, allowing us to either get a TokenStream back or a compile error message. You can run the added tests directly with this meson command: meson test rust-qemu-api-macros-tests Signed-off-by: Manos Pitsidianakis <manos.pitsidiana...@linaro.org> --- Manos Pitsidianakis (2): rust/qemu-api-macros: normalize TryInto output rust/qemu-api-macros: add unit tests rust/qemu-api-macros/meson.build | 3 + rust/qemu-api-macros/src/lib.rs | 7 +- rust/qemu-api-macros/src/tests.rs | 135 ++++++++++++++++++++++++++++++++++++++ rust/qemu-api-macros/src/utils.rs | 1 + 4 files changed, 144 insertions(+), 2 deletions(-) --- base-commit: c77283dd5d79149f4e7e9edd00f65416c648ee59 change-id: 20250704-rust_add_derive_macro_unit_tests-3e7daf905d62 -- γαῖα πυρί μιχθήτω