Code coverage for macros

I have a workflow that runs cargo test with the right options being passed to LLVM etc to produce coverage data I can feed up to Codecov. However, the code I'm most interested in testing is a proc macro which doesn't show up in that listing.

Does anyone know if it's possible to get coverage for proc macros that run while building tests, rather than when they run? That is, I run unit tests that depend on the macro, and get code coverage results for both the macro body and also the test harness that calls to the macro.

An alternative idea I had was manually driving the macros as though they were normal functions by feeding them token streams, but I'd like to avoid that as it seems awkward and fragile to pull off

The tarpaulin README recommends runtime-macros for getting the coverage of procedural macros.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.