1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use std::path::PathBuf;
16 let oldhome = var("HOME");
18 set_var("HOME", "/home/MountainView");
19 assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
22 if cfg!(target_os = "android") {
23 assert!(home_dir().is_none());
25 assert!(home_dir().is_some());
31 let oldhome = var("HOME");
32 let olduserprofile = var("USERPROFILE");
35 remove_var("USERPROFILE");
37 assert!(home_dir().is_some());
39 set_var("HOME", "/home/MountainView");
40 assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
44 set_var("USERPROFILE", "/home/MountainView");
45 assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
47 set_var("HOME", "/home/MountainView");
48 set_var("USERPROFILE", "/home/PaloAlto");
49 assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));