-
Notifications
You must be signed in to change notification settings - Fork 185
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
Cleanup Custom Tests #473
Cleanup Custom Tests #473
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me, but I am not sure we need to specifically test that custom implementations do not overwrite the default backends.
Also, I have an alternative proposal. I think we can do the following:
// in lib.rs
cfg_if! {
if #[cfg(all(test, test_rdrand))] {
mod lazy;
#[path = "rdrand.rs"] mod imp;
} else if #[cfg(all(test, test_custom, feature = "custom"))] {
use custom as imp;
} else if #[cfg( ... ))] {
// ...
}
}
// in tests module:
register_custom_getrandom!(mock_rng);
#[cfg(not(all(feature = "custom", test_custom)))]
#[test]
fn mock_rng_is_not_used() {
// ..
}
This will eliminate the weird juggling around RDRAND and will allow us to test a custom implementation on standard Linux targets. Using cfg(test)
will ensure that the testing branches will not escape outside of this crate.
971e0ee
to
195e2bf
Compare
@newpavlov @briansmith PTAL. I moved the custom.rs tests back to being an integration test, so both supported and unsupported platforms are now tested without changing the
I think its important to test that:
My concern with changing the
I agree that RDRAND has some weird juggling, but that's probably best left for discussion in #476 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot more sense to me. Just a couple comments.
This marks the `tests/custom.rs` test as requiring the `"custom"` feature. It also: - Simplifies the registered custom RNG - Makes sure the custom RNG _is not_ used on supported platforms - Makes sure the custom RNG _is_ used on unsupported platforms Signed-off-by: Joe Richey <[email protected]>
This moves the tests for the custom RNG registration into custom.rs. It also:
Split out from #471 CC @briansmith