2015-01-27 14:20:58 -06:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-03-05 20:33:58 -06:00
|
|
|
#![feature(path)]
|
2015-03-18 11:14:54 -05:00
|
|
|
|
2015-01-27 14:20:58 -06:00
|
|
|
use std::env::*;
|
2015-02-23 12:59:17 -06:00
|
|
|
use std::path::PathBuf;
|
2015-01-27 14:20:58 -06:00
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn main() {
|
|
|
|
let oldhome = var("HOME");
|
|
|
|
|
|
|
|
set_var("HOME", "/home/MountainView");
|
2015-03-18 11:14:54 -05:00
|
|
|
assert!(home_dir() == Some(PathBuf::from("/home/MountainView")));
|
2015-01-27 14:20:58 -06:00
|
|
|
|
|
|
|
remove_var("HOME");
|
2015-02-02 13:04:58 -06:00
|
|
|
if cfg!(target_os = "android") {
|
|
|
|
assert!(home_dir().is_none());
|
|
|
|
} else {
|
|
|
|
assert!(home_dir().is_some());
|
|
|
|
}
|
2015-01-27 14:20:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
fn main() {
|
|
|
|
let oldhome = var("HOME");
|
|
|
|
let olduserprofile = var("USERPROFILE");
|
|
|
|
|
|
|
|
remove_var("HOME");
|
|
|
|
remove_var("USERPROFILE");
|
|
|
|
|
|
|
|
assert!(home_dir().is_some());
|
|
|
|
|
|
|
|
set_var("HOME", "/home/MountainView");
|
2015-03-18 11:14:54 -05:00
|
|
|
assert!(home_dir() == Some(PathBuf::from("/home/MountainView")));
|
2015-01-27 14:20:58 -06:00
|
|
|
|
|
|
|
remove_var("HOME");
|
|
|
|
|
|
|
|
set_var("USERPROFILE", "/home/MountainView");
|
2015-03-18 11:14:54 -05:00
|
|
|
assert!(home_dir() == Some(PathBuf::from("/home/MountainView")));
|
2015-01-27 14:20:58 -06:00
|
|
|
|
|
|
|
set_var("HOME", "/home/MountainView");
|
|
|
|
set_var("USERPROFILE", "/home/PaloAlto");
|
2015-03-18 11:14:54 -05:00
|
|
|
assert!(home_dir() == Some(PathBuf::from("/home/MountainView")));
|
2015-01-27 14:20:58 -06:00
|
|
|
}
|