From 1ecc789deaa695d2900ec3a9a5f20dfd412cb03a Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Sat, 25 Jun 2022 23:23:24 +0300 Subject: [PATCH 1/4] test_realpath: fixed test to be the one that was supposed to be and added non-passing test --- tests/by-util/test_realpath.rs | 32 ++++++++++++++++++++++++++++---- tests/common/util.rs | 9 +++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index e0875cc77..e188929bf 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -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"); +} diff --git a/tests/common/util.rs b/tests/common/util.rs index d601b90d8..fe6c64a90 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -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)) { From b3642b64c5b440f6b8a0975873ad4fe54ea77090 Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Sat, 25 Jun 2022 23:33:22 +0300 Subject: [PATCH 2/4] test_realpath: reformatted using rustfmt --- tests/by-util/test_realpath.rs | 9 +++++---- tests/common/util.rs | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index e188929bf..cf5f77338 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -220,10 +220,11 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() { .arg("dir1/foo2") .arg("dir1/foo3") .run() - .stdout_is(format!("{}\n{}\n", - at.plus_as_string("dir2/bar"), - at.plus_as_string("dir2/baz")) - ) + .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)] diff --git a/tests/common/util.rs b/tests/common/util.rs index fe6c64a90..580dd1584 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -702,7 +702,10 @@ impl AtPath { } pub fn relative_symlink_file(&self, original: &str, link: &str) { - log_info("symlink", &format!("{},{}", original, &self.plus_as_string(link))); + log_info( + "symlink", + &format!("{},{}", original, &self.plus_as_string(link)), + ); symlink_file(original, &self.plus(link)).unwrap(); } @@ -719,7 +722,10 @@ impl AtPath { } pub fn relative_symlink_dir(&self, original: &str, link: &str) { - log_info("symlink", &format!("{},{}", original, &self.plus_as_string(link))); + log_info( + "symlink", + &format!("{},{}", original, &self.plus_as_string(link)), + ); symlink_dir(original, &self.plus(link)).unwrap(); } From 9b2fa397609081776276a85fc9f5b4beab961cd6 Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Sun, 26 Jun 2022 01:07:55 +0300 Subject: [PATCH 3/4] test_realpath: get back to contains to pass in MacOs --- tests/by-util/test_realpath.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index cf5f77338..fd104bb79 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -220,11 +220,8 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() { .arg("dir1/foo2") .arg("dir1/foo3") .run() - .stdout_is(format!( - "{}\n{}\n", - at.plus_as_string("dir2/bar"), - at.plus_as_string("dir2/baz") - )) + .stdout_contains("/dir2/bar\n") + .stdout_contains("/dir2/baz\n") .stderr_is("realpath: dir1/foo2: No such file or directory\n"); #[cfg(windows)] From 4e936d2d0d8314008a3b06ee048285cb0ac7f4bb Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Sun, 26 Jun 2022 01:08:28 +0300 Subject: [PATCH 4/4] test_realpath: include issue id to ignored testcase --- tests/by-util/test_realpath.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index fd104bb79..b08975f4d 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -235,7 +235,7 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() { } #[test] -#[ignore] +#[ignore = "issue #3669"] fn test_realpath_when_symlink_part_is_missing() { let (at, mut ucmd) = at_and_ucmd!();