I want to use #![feature(custom_test_frameworks)]
, but if possible only conditionally enable it via #[cfg(not(target_os = "custom_os_name"))]
. I would still prefer to have the option to run some tests directly on my host system using rusts libtest, but apparently I'm not allowed to modify features via cfg
:
Error Message:
note: inner attributes, like `#![no_std]`, annotate the item enclosing them,
and are usually found at the beginning of source files. Outer attributes, like
`#[test]`, annotate the item following them.
Is there any other way to conditionally enable an "inner attribute"?
You can use #[cfg_attr]
to apply an attribute based on some other features.
In your case, you can do:
#![cfg_attr(
not(target_os = "custom_os_name"),
feature(custom_test_frameworks)
)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With