Skip to content

Commit 5edac6c

Browse files
committed
Add a test for the env_override
1 parent a7f23d9 commit 5edac6c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

crates/std_detect/src/detect/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,10 @@ pub fn features() -> impl Iterator<Item = (&'static str, bool)> {
135135
}
136136
impl_()
137137
}
138+
139+
#[test]
140+
fn features_roundtrip() {
141+
for (f, _) in features() {
142+
let _ = Feature::from_str(f).unwrap();
143+
}
144+
}

crates/std_detect/src/detect/os/x86.rs

+19
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,25 @@ mod tests {
295295
println!("rtm: {:?}", is_x86_feature_detected!("rtm"));
296296
}
297297

298+
#[cfg(feature = "std_detect_env_override")]
299+
#[test]
300+
fn env_override_no_avx() {
301+
if let Ok(disable) = crate::env::var("RUST_STD_DETECT_UNSTABLE") {
302+
let information = cupid::master().unwrap();
303+
for d in disable.split(" ") {
304+
match d {
305+
"avx" => if information.avx() {
306+
assert_ne!(is_x86_feature_detected!("avx"), information.avx())
307+
}
308+
"avx2" => if information.avx2() {
309+
assert_ne!(is_x86_feature_detected!("avx2"), information.avx2())
310+
}
311+
_ => {}
312+
}
313+
}
314+
}
315+
}
316+
298317
#[test]
299318
fn compare_with_cupid() {
300319
let information = cupid::master().unwrap();

0 commit comments

Comments
 (0)