2019-04-21 06:43:53 -05:00
|
|
|
//ignore-windows: TODO env var emulation stubbed out on Windows
|
2018-10-20 18:31:46 -05:00
|
|
|
|
2018-10-16 05:44:04 -05:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
fn main() {
|
2020-03-05 16:25:55 -06:00
|
|
|
// Test that miri environment is isolated when communication is disabled.
|
|
|
|
// (`MIRI_ENV_VAR_TEST` is set by the test harness.)
|
|
|
|
assert_eq!(env::var("MIRI_ENV_VAR_TEST"), Err(env::VarError::NotPresent));
|
|
|
|
|
|
|
|
// Test base state.
|
|
|
|
println!("{:#?}", env::vars().collect::<Vec<_>>());
|
2018-10-16 05:44:04 -05:00
|
|
|
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
|
2020-03-05 16:25:55 -06:00
|
|
|
|
|
|
|
// Set the variable.
|
2018-10-16 05:44:04 -05:00
|
|
|
env::set_var("MIRI_TEST", "the answer");
|
|
|
|
assert_eq!(env::var("MIRI_TEST"), Ok("the answer".to_owned()));
|
2020-03-05 16:25:55 -06:00
|
|
|
println!("{:#?}", env::vars().collect::<Vec<_>>());
|
|
|
|
|
|
|
|
// Change the variable.
|
|
|
|
env::set_var("MIRI_TEST", "42");
|
|
|
|
assert_eq!(env::var("MIRI_TEST"), Ok("42".to_owned()));
|
|
|
|
println!("{:#?}", env::vars().collect::<Vec<_>>());
|
|
|
|
|
|
|
|
// Remove the variable.
|
|
|
|
env::remove_var("MIRI_TEST");
|
|
|
|
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
|
|
|
|
println!("{:#?}", env::vars().collect::<Vec<_>>());
|
2018-10-16 05:44:04 -05:00
|
|
|
}
|