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

Opt-in into Miri tests #1758

Closed
JakubKoralewski opened this issue Apr 6, 2021 · 2 comments
Closed

Opt-in into Miri tests #1758

JakubKoralewski opened this issue Apr 6, 2021 · 2 comments

Comments

@JakubKoralewski
Copy link

I'm currently blocked by #602, #1719, so most of my tests are async tokio tests. I have some uses of unsafe and I'd like to enable Miri only for the tests that somehow use the structs and fns that use the unsafe without having async involved in any way. I guess I could ignore every single test case and just not ignore the few that I have that check the unsafe parts but I think this could be easier.

If this has a workaround please update the README under https://github.com/rust-lang/miri#using-miri to let ppl know this is possible.

Also maybe this could more easily let ignore tests resulting in helping with #654.

@RalfJung
Copy link
Member

RalfJung commented Apr 6, 2021

Miri has no control over which tests are run -- it just interprets the test harness in the same way that that test harness would usually be executed when being run outside Miri. The only extra bit is that cfg(miri) is set when "building" code for Miri. So to achieve this, look for existing test harness and cfg features that might be useful:

  • You could run the tests with cargo miri test miri, which corresponds to cargo test miri, i.e., it only runs tests that have "miri" in the name.
  • You could #![cfg(not(miri))] most files defining tests, and put all the tests you want run in Miri in a single file that does not have this attribute.

Does one of these work for you?
I don't think there is a one-size-fits-all solution here, but Rust and its test runner are hopefully flexible enough to offer some way to do this. Miri can't really do anything beyond that.

@JakubKoralewski
Copy link
Author

I see thanks. I'll go either for cargo miri test miri or will attempt to add a feature flag to my project and see if I can add some sort of test_miri feature to the Miri specific tests and run those only, cause I think filtering with cargo test miri may actually build all the integration tests.

Thanks

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

2 participants