-
Notifications
You must be signed in to change notification settings - Fork 40
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
skip cases based on feature flag? #234
Comments
Can you just check if it works if you don't use Maybe the compiler process |
Without
This either runs all tests if the "cloud" feature flag is set, or none (if it's not set). Priorities of procedural macros is something I didn't expose myself with yet, so sorry for not being a lot of help 🙈 |
Ok, you should use #[rstest]
#[case::grpc(make_grpc_directory_service_client().await)]
#[case::memory(directoryservice::from_addr("memory://").await.unwrap())]
#[case::sled(directoryservice::from_addr("sled://").await.unwrap())]
#[cfg_attr(feature = "cloud", case::bigtable(make_bigtable().await))]
#[tokio::test]
async fn pingpong(#[case] directory_service: impl DirectoryService) {
let resp = directory_service.get(&DIRECTORY_A.digest()).await;
assert!(resp.unwrap().is_none())
} That should work also with |
Thanks! Indeed this works, also for template/apply! Let me check if there's a good place to document this (maybe somewhere close to test cases). |
I opened #236, PTAL! |
* README: document cfg_attr for cases Fixes #234. * rstest_macros: document cfg_attr for cases
I use
rstest
to run a bunch of "acceptance tests" across different implementations all exposing the same trait.I use
rstest_reuse
's#[template]
and#[apply(…)]
to write a template containing all implementations I want to test with (as test cases), and useapply
for each individual test:This keeps the amount of boilerplate for each test case to a minimum, thanks a lot :-)
Now I want to add an additional store implementation, but its code is behind a feature flag.
It seems it's not possible to have a single
#[case:…]
with a#[cfg(feature = "cloud")]
- it doesn't apply to the macro(s), but entirely enables/disables the wholepub fn directory_services
template function:Currently my only way out seems to be having two implementations of
pub fn directory_services
, one without, and one with the feature flag:This obviously won't scale when feature flags get more (granular). Any thoughts on how to do this? Maybe adding an optional argument, allowing to express a cfg!() expression for when a case should get included?
The text was updated successfully, but these errors were encountered: