]> git.lizzy.rs Git - rust.git/blob - tests/pass/current_dir.rs
make tests pass again
[rust.git] / tests / pass / current_dir.rs
1 //@compile-flags: -Zmiri-disable-isolation
2 use std::env;
3 use std::io::ErrorKind;
4
5 fn main() {
6     // Test that `getcwd` is available
7     let cwd = env::current_dir().unwrap();
8     // Test that changing dir to `..` actually sets the current directory to the parent of `cwd`.
9     // The only exception here is if `cwd` is the root directory, then changing directory must
10     // keep the current directory equal to `cwd`.
11     let parent = cwd.parent().unwrap_or(&cwd);
12     // Test that `chdir` is available
13     assert!(env::set_current_dir("..").is_ok());
14     // Test that `..` goes to the parent directory
15     assert_eq!(env::current_dir().unwrap(), parent);
16     // Test that `chdir` to a non-existing directory returns a proper error
17     assert_eq!(env::set_current_dir("thisdoesnotexist").unwrap_err().kind(), ErrorKind::NotFound);
18 }