I want to enable different features of dependencies in when using cargo build
and when using cargo test
. How would I go about this? Is this even supported?
Say I have a crate named lib
with the contents of src/lib.rs
:
pub fn feature_foo_enabled() -> bool {
cfg!(feature="foo")
}
And a crate named bin
with the contents of src/main.rs
:
extern crate lib;
fn main() {
println!("Foo enabled: {}",lib::feature_foo_enabled());
}
#[test]
fn test() {
println!("Foo enabled: {}",lib::feature_foo_enabled());
assert!(false)
}
How do I make these output something different on cargo run
and cargo test
?