#code-coverage #proc-macro #macro-expansion #macro

sylvia-runtime-macros

Simulate expansion of procedural macros at run time

1 unstable release

0.6.0 Oct 19, 2022

#2479 in Development tools

Download history 37/week @ 2024-07-28 27/week @ 2024-08-04 7/week @ 2024-08-11 44/week @ 2024-08-18 43/week @ 2024-08-25 13/week @ 2024-09-01 14/week @ 2024-09-08 21/week @ 2024-09-15 30/week @ 2024-09-22 27/week @ 2024-09-29 27/week @ 2024-10-06 28/week @ 2024-10-13 16/week @ 2024-10-20 16/week @ 2024-10-27 15/week @ 2024-11-03 16/week @ 2024-11-10

63 downloads per month
Used in sylvia-derive

MIT/Apache

24KB
339 lines

sylvia-runtime-macros

Fork of runtime-macros with custom derive support

This crate offers a way to emulate the process of procedural macro expansion at run time. It is intended for use with code coverage tools like tarpaulin, which can't measure the code coverage of anything that happens at compile time.

Currently it supports functionlike attributes and custom derives. It does not support custom attributes as macros, though custom helper attributes on custom derives work.

To use it, add a test case to your procedural macro crate that calls emulate_macro_expansion on a .rs file that calls the macro. Most likely, all the files you'll want to use it on will be in your /tests directory. Once you've completed this step, any code coverage tool that works with your crate's test cases will be able to report on how thoroughly you've tested the macro.

See the /examples directory in the repository for working examples. Note that the custom_assert example requires nightly at present.

Development note

To run tests, run cargo test -- --test-threads 1 - Tarpaulin is not capable of running multiple instances at once

Dependencies

~1.5MB
~37K SLoC