2019-09-24 14:42:38 -05:00
|
|
|
// ignore-windows: TODO the windows hook is not done yet
|
|
|
|
// compile-flags: -Zmiri-disable-isolation
|
|
|
|
use std::env;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// test that `getcwd` is available
|
|
|
|
let cwd = env::current_dir().unwrap();
|
2019-10-11 02:35:50 -05:00
|
|
|
// test that changing dir to `..` actually sets the current directory to the parent of `cwd`.
|
|
|
|
// the only exception here is if `cwd` is the root directory, then changing directory must
|
|
|
|
// keep the current directory equal to `cwd`.
|
2019-09-24 14:42:38 -05:00
|
|
|
let parent = cwd.parent().unwrap_or(&cwd);
|
|
|
|
// test that `chdir` is available
|
|
|
|
assert!(env::set_current_dir(&Path::new("..")).is_ok());
|
|
|
|
// test that `..` goes to the parent directory
|
|
|
|
assert_eq!(env::current_dir().unwrap(), parent);
|
|
|
|
}
|