Add comments to explain the chdir test

This commit is contained in:
Christian Poveda
2019-10-11 02:35:50 -05:00
parent c8df0171e8
commit 8368d4f2b4
@@ -6,6 +6,9 @@
fn main() {
// test that `getcwd` is available
let cwd = env::current_dir().unwrap();
// 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`.
let parent = cwd.parent().unwrap_or(&cwd);
// test that `chdir` is available
assert!(env::set_current_dir(&Path::new("..")).is_ok());