Expand description
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, runtime-macros
only works with functionlike!
procedural macros. Custom
derive may be supported in the future if there’s demand.
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.
Enums§
- The error type for
emulate_macro_expansion_fallible
. If anything goes wrong during the file loading or macro expansion, this type describes it.
Functions§
- Parses the given Rust source file, finding attributes macro expansions using
macro_path
. Each time it finds one, it callsderive_fn
, passing it asyn::DeriveInput
. - Parses the given Rust source file, finding custom drives macro expansions using
macro_path
. Each time it finds one, it callsderive_fn
, passing it asyn::DeriveInput
. - emulate_
macro_ expansion Deprecated This type is likeemulate_macro_expansion_fallible
but automatically unwraps any errors it encounters. As such, it’s deprecated due to being less flexible. - Parses the given Rust source file, finding functionlike macro expansions using
macro_path
. Each time it finds one, it callsproc_macro_fn
, passing it the innerTokenStream
just as if the macro were being expanded. The only effect is to verify that the macro doesn’t panic, as the expansion is not actually applied to the AST or the source code.