Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the output of zerocopy-derive #367

Open
3 tasks
joshlf opened this issue Sep 10, 2023 · 1 comment
Open
3 tasks

Test the output of zerocopy-derive #367

joshlf opened this issue Sep 10, 2023 · 1 comment
Labels
experience-hard This issue is hard, and requires a lot of experience help wanted Extra attention is needed

Comments

@joshlf
Copy link
Member

joshlf commented Sep 10, 2023

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:

  • Add synstructure dev-dependency to zerocopy-derive
  • Add a basic test and confirm that it works (this and the previous step could be their own PR)
  • Come up with as many test cases as you can think of! Consider using our existing tests (zerocopy-derive/tests/*.rs) and trybuild tests (zerocopy-derive/tests/ui-*.rs) to help give you ideas.
@joshlf joshlf added help wanted Extra attention is needed experience-hard This issue is hard, and requires a lot of experience labels Sep 10, 2023
@joshlf joshlf added the Hacktoberfest https://hacktoberfest.com/participation/ label Sep 29, 2023
@joshlf joshlf removed the Hacktoberfest https://hacktoberfest.com/participation/ label Oct 23, 2023
@tommy-gilligan
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experience-hard This issue is hard, and requires a lot of experience help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants