mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
Merge branch 'main' into cp-lb
This commit is contained in:
commit
8df4f0bb4d
4 changed files with 74 additions and 15 deletions
|
@ -149,8 +149,8 @@ fn test_realpath_dangling() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.symlink_file("nonexistent-file", "link");
|
||||
ucmd.arg("link")
|
||||
.succeeds()
|
||||
.stdout_only(at.plus_as_string("nonexistent-file\n"));
|
||||
.fails()
|
||||
.stderr_contains("realpath: link: No such file or directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -202,3 +202,34 @@ fn test_realpath_missing() {
|
|||
.succeeds()
|
||||
.stdout_only(expect);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_when_symlink_is_absolute_and_enoent() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("dir2");
|
||||
at.touch("dir2/bar");
|
||||
|
||||
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());
|
||||
|
||||
#[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");
|
||||
|
||||
#[cfg(windows)]
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -701,6 +701,11 @@ impl AtPath {
|
|||
symlink_file(&self.plus(original), &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
||||
log_info("symlink", &format!("{},{}", original, link));
|
||||
symlink_file(original, link).unwrap();
|
||||
}
|
||||
|
||||
pub fn symlink_dir(&self, original: &str, link: &str) {
|
||||
log_info(
|
||||
"symlink",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue