google / zerocopy

https://discord.gg/MAvWH2R6zk
Apache License 2.0
1.56k stars 98 forks source link

Test the output of zerocopy-derive #367

Closed joshlf closed 2 weeks ago

joshlf commented 1 year ago

As zerocopy-derive gets more powerful, it becomes harder to test every edge case just through compile-success and compile-fail tests. One way we could test at a higher fidelity would be to assert the exact token stream output as a result of deriving traits on various types. This would be in some ways easier to verify for a human reviewer, and would be more stable than compiler error messages (a problem that plagues our existing trybuild tests, and requires us to keep three separate copies of the .stderr files - one for each toolchain we use in CI).

A few ways we could do this:

I'm currently leaning towards test_derive!, as it seems to do exactly what we want.

Mentoring

Steps:

tommy-gilligan commented 10 months ago

I've had a bit of a go at this (with synstructure) but I can't manage to make test_derive! work with zerocopy-derive's derives. I don't have much experience with macros, so I don't feel confident calling it definitively but I think test_derive! can only really be used with macros built using synstructure.