extern crate autocfg;
use std::env;
mod support;
#[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 out = support::out_dir();
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::with_dir(out.as_ref()).unwrap();
if rustc == Some(false) || workspace == Some(false) {
assert!(!ac.probe_type("usize"));
} else {
assert!(ac.probe_type("usize"));
assert!(!ac.probe_type("mesize"));
}
assert!(ac.probe_rustc_version(1, 0));
}
}
env::set_var("RUSTC_WRAPPER", "./tests/wrap_ignored");
env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false");
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(ac.probe_type("mesize"));
assert!(ac.probe_rustc_version(12345, 6789));
}