1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

test_realpath: fixed test to be the one that was supposed to be and

added non-passing test
This commit is contained in:
Niyaz Nigmatullin 2022-06-25 23:23:24 +03:00 committed by Sylvestre Ledru
parent a66527e3e2
commit 1ecc789dea
2 changed files with 35 additions and 6 deletions

View file

@ -213,16 +213,18 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() {
at.mkdir("dir1");
at.symlink_file("dir2/bar", "dir1/foo1");
at.symlink_file("/dir2/bar", "dir1/foo2");
at.relative_symlink_file("dir2/baz", at.plus("dir1/foo3").to_str().unwrap());
at.relative_symlink_file("../dir2/baz", "dir1/foo3");
#[cfg(unix)]
ucmd.arg("dir1/foo1")
.arg("dir1/foo2")
.arg("dir1/foo3")
.run()
.stdout_contains("/dir2/bar\n")
.stdout_contains("/dir2/baz\n")
.stderr_is("realpath: dir1/foo2: No such file or directory");
.stdout_is(format!("{}\n{}\n",
at.plus_as_string("dir2/bar"),
at.plus_as_string("dir2/baz"))
)
.stderr_is("realpath: dir1/foo2: No such file or directory\n");
#[cfg(windows)]
ucmd.arg("dir1/foo1")
@ -233,3 +235,25 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() {
.stdout_contains("\\dir2\\baz\n")
.stderr_is("realpath: dir1/foo2: No such file or directory");
}
#[test]
#[ignore]
fn test_realpath_when_symlink_part_is_missing() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("dir2");
at.touch("dir2/bar");
at.mkdir("dir1");
at.relative_symlink_file("../dir2/bar", "dir1/foo1");
at.relative_symlink_file("dir2/bar", "dir1/foo2");
at.relative_symlink_file("../dir2/baz", "dir1/foo3");
at.symlink_file("dir3/bar", "dir1/foo4");
ucmd.args(&["dir1/foo1", "dir1/foo2", "dir1/foo3", "dir1/foo4"])
.run()
.stdout_contains(at.plus_as_string("dir2/bar") + "\n")
.stdout_contains(at.plus_as_string("dir2/baz") + "\n")
.stderr_contains("realpath: dir1/foo2: No such file or directory\n")
.stderr_contains("realpath: dir1/foo4: No such file or directory\n");
}