Test case for cd

This commit is contained in:
Zhenping Zhao 2024-12-19 14:27:27 -08:00
parent d7fdf96eb1
commit 3122d918bc

View file

@ -323,3 +323,39 @@ fn pwd_recovery() {
assert_eq!(actual.out, "/");
}
#[cfg(windows)]
#[test]
fn filesystem_from_non_root_change_to_another_drive_non_root_then_using_relative_path_go_back() {
Playground::setup("cd_test_22", |dirs, sandbox| {
sandbox.mkdir("test_folder");
let _actual = nu!(
cwd: dirs.test(),
r#"
touch test_folder/test_file.txt
"#
);
assert!(dirs.test.exists());
assert!(dirs.test.join("test_folder").exists());
assert!(dirs.test.join("test_folder").join("test_file.txt").exists());
let _actual = nu!(
cwd: dirs.test(),
r#"
subst X: /D | touch out
subst X: test_folder
cd x:
touch test_file_on_x.txt
echo $env.PWD
cd -
subst X: /D | touch out
echo $env.PWD
"#
);
assert!(dirs.test.exists());
assert!(dirs.test.join("test_folder").exists());
assert!(_actual.out.ends_with(r"\cd_test_22"));
assert!(_actual.err.is_empty());
assert!(dirs.test.join("test_folder").join("test_file_on_x.txt").exists());
})
}