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

Macro tests should also ensure stuff compiles #617

Open
Manishearth opened this issue Aug 1, 2024 · 1 comment
Open

Macro tests should also ensure stuff compiles #617

Manishearth opened this issue Aug 1, 2024 · 1 comment

Comments

@Manishearth
Copy link
Contributor

Manishearth commented Aug 1, 2024

I think instead of having insta tests in lib.rs, the macro should test things by having files in tests/, which get run with the macro, and also have atests/insta_runner.rs` that runs the test files through the macro and generates insta snapshots.

@Manishearth
Copy link
Contributor Author

Manishearth commented Aug 2, 2024

Actually, I think the best path forward is this:

  • All macro insta tests become tests/foo.rs, and are compiled (but have no run behavior)
  • Macro gets tests/snapshots.rs that iterates all other tests and insta-snapshots their codegen
  • feature_tests and examples get an additional gen pass that iterates each file and codegens it into macro_expanded/ or something. These files just exist and are not expected to compile (we don't hook them up to a Cargo.toml or anything, since the feature_test crate compilation already tests this end-to-end)

I think this would be particularly useful for other people hacking on Diplomat, and of course makes it easier to review macro changes. So far we basically haven't touched the macro much, but I've also found myself afraid of touching the macro because I don't want to subtly break FFI. having more checked in generated stuff would greatly help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant