tests/realpath: add trailing slash usage tests

This commit is contained in:
Niyaz Nigmatullin 2022-08-15 22:40:29 +03:00
parent 1c6f71e0e1
commit 94860f8af6

View file

@ -364,3 +364,92 @@ fn test_relative() {
.succeeds()
.stdout_is(".\nusr\n"); // spell-checker:disable-line
}
#[test]
fn test_realpath_trailing_slash() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("file");
at.mkdir("dir");
at.relative_symlink_file("file", "link_file");
at.relative_symlink_dir("dir", "link_dir");
at.relative_symlink_dir("no_dir", "link_no_dir");
scene
.ucmd()
.arg("link_file")
.succeeds()
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
scene.ucmd().arg("link_file/").fails().code_is(1);
scene
.ucmd()
.arg("link_dir")
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.arg("link_dir/")
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.arg("link_no_dir")
.succeeds()
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.arg("link_no_dir/")
.succeeds()
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-e", "link_file"])
.succeeds()
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
scene.ucmd().args(&["-e", "link_file/"]).fails().code_is(1);
scene
.ucmd()
.args(&["-e", "link_dir"])
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-e", "link_dir/"])
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene.ucmd().args(&["-e", "link_no_dir"]).fails().code_is(1);
scene
.ucmd()
.args(&["-e", "link_no_dir/"])
.fails()
.code_is(1);
scene
.ucmd()
.args(&["-m", "link_file"])
.succeeds()
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-m", "link_file/"])
.succeeds()
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-m", "link_dir"])
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-m", "link_dir/"])
.succeeds()
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-m", "link_no_dir"])
.succeeds()
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
scene
.ucmd()
.args(&["-m", "link_no_dir/"])
.succeeds()
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
}