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

Unit tests of proc-macro crates #2102

Open
dtolnay opened this issue May 5, 2022 · 2 comments
Open

Unit tests of proc-macro crates #2102

dtolnay opened this issue May 5, 2022 · 2 comments
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@dtolnay
Copy link
Member

dtolnay commented May 5, 2022

Running cargo miri test --lib on a crate that has [lib] proc-macro = true in Cargo.toml prints the following and does not run the unit tests:

Running unit tests of `proc-macro` crates is not currently supported by Miri.

Unit tests inside proc macro crates are allowed and supported by cargo test --lib.

I found this message originated a year ago from #1675 but I did not find a corresponding issue that I could follow, so here is one.

@dtolnay
Copy link
Member Author

dtolnay commented May 5, 2022

I'm not sure whether this would be blocked on #1542. Proc macro unit tests when run by cargo test are not allowed to instantiate proc macro bridge objects (it's the same panic as if you had tried to instantiate one from a bin crate) so implementing the proc macro server API wouldn't be necessary to support running unit tests.

That said, it would be really slick if cargo miri test would allow working with proc macro objects from a unit test.

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-cargo Area: affects the cargo wrapper (cargo miri) labels May 5, 2022
@RalfJung
Copy link
Member

RalfJung commented May 5, 2022

Good point, we should certainly track this somewhere.

Conceptually cargo treats proc-macros as being on the host while Miri is responsible for the target, so I am not sure if and how this will be possible. I am not deeply familiar with proc-macros and how cargo treats them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

2 participants