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:
parent
a66527e3e2
commit
1ecc789dea
2 changed files with 35 additions and 6 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -702,8 +702,8 @@ impl AtPath {
|
|||
}
|
||||
|
||||
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
||||
log_info("symlink", &format!("{},{}", original, link));
|
||||
symlink_file(original, link).unwrap();
|
||||
log_info("symlink", &format!("{},{}", original, &self.plus_as_string(link)));
|
||||
symlink_file(original, &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn symlink_dir(&self, original: &str, link: &str) {
|
||||
|
@ -718,6 +718,11 @@ impl AtPath {
|
|||
symlink_dir(&self.plus(original), &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
|
||||
log_info("symlink", &format!("{},{}", original, &self.plus_as_string(link)));
|
||||
symlink_dir(original, &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn is_symlink(&self, path: &str) -> bool {
|
||||
log_info("is_symlink", self.plus_as_string(path));
|
||||
match fs::symlink_metadata(&self.plus(path)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue