extern crate autocfg;
use std::env;
#[test]
#[cfg(unix)] fn test_wrappers() {
fn set(name: &str, value: Option<bool>) {
match value {
Some(true) => env::set_var(name, "/usr/bin/env"),
Some(false) => env::set_var(name, "/bin/false"),
None => env::remove_var(name),
}
}
let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf();
env::set_var("OUT_DIR", &format!("{}", dir.display()));
env::set_var("CARGO_ENCODED_RUSTFLAGS", "");
let variants = [None, Some(true), Some(false)];
for &workspace in &variants {
for &rustc in &variants {
set("RUSTC_WRAPPER", rustc);
set("RUSTC_WORKSPACE_WRAPPER", workspace);
let ac = autocfg::AutoCfg::new().unwrap();
if rustc == Some(false) || workspace == Some(false) {
assert!(!ac.probe_type("usize"));
} else {
assert!(ac.probe_type("usize"));
assert!(!ac.probe_type("mesize"));
}
}
}
env::set_var("RUSTC_WRAPPER", "/bin/true");
env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false");
let ac = autocfg::AutoCfg::new().unwrap();
assert!(ac.probe_type("mesize")); }