From 84330ca938bdd441f341d28a44e480f8352f43ed Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 22:15:57 +0200 Subject: [PATCH 1/6] gnu/test: rm: update one of the test to match what we do --- util/build-gnu.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 64329bd0c..c575e84f6 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -98,4 +98,13 @@ sed -i 's|seq |/usr/bin/seq |' tests/misc/sort-discrim.sh sed -i 's|seq \$|/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh sed -i 's|cat |/usr/bin/timeout 0.1 cat |' tests/misc/cat-self.sh + + +#### Adjust tests to make them work with Rust/coreutils +# in some cases, what we are doing in rust/coreutils is good (or better) +# we should not regress our project just to match what GNU is going. +# So, do some changes on the fly + +sed -i -e "s|rm: cannot remove 'e/slink'|rm: cannot remove 'e'|g" tests/rm/fail-eacces.sh + test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" From 6a8d15f92eee778fe583d8680a9af7bcc9e8a46e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 22:19:14 +0200 Subject: [PATCH 2/6] gnu/rm: match gnu's output --- src/uu/rm/src/rm.rs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 43a4f4780..ba764034a 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -255,7 +255,18 @@ fn handle_dir(path: &Path, options: &Options) -> bool { // correctly on Windows if let Err(e) = remove_dir_all(path) { had_err = true; - show_error!("could not remove '{}': {}", path.display(), e); + if e.kind() == std::io::ErrorKind::PermissionDenied { + // GNU compatibility (rm/fail-eacces.sh) + // here, GNU doesn't use some kind of remove_dir_all + // It will show directory+file + show_error!( + "cannot remove '{}': {}", + path.display(), + "Permission denied" + ); + } else { + show_error!("cannot remove '{}': {}", path.display(), e); + } } } else { let mut dirs: VecDeque = VecDeque::new(); @@ -314,7 +325,16 @@ fn remove_dir(path: &Path, options: &Options) -> bool { } } Err(e) => { - show_error!("cannot remove '{}': {}", path.display(), e); + if e.kind() == std::io::ErrorKind::PermissionDenied { + // GNU compatibility (rm/fail-eacces.sh) + show_error!( + "cannot remove '{}': {}", + path.display(), + "Permission denied" + ); + } else { + show_error!("cannot remove '{}': {}", path.display(), e); + } return true; } } @@ -352,7 +372,16 @@ fn remove_file(path: &Path, options: &Options) -> bool { } } Err(e) => { - show_error!("removing '{}': {}", path.display(), e); + if e.kind() == std::io::ErrorKind::PermissionDenied { + // GNU compatibility (rm/fail-eacces.sh) + show_error!( + "cannot remove '{}': {}", + path.display(), + "Permission denied" + ); + } else { + show_error!("cannot remove '{}': {}", path.display(), e); + } return true; } } From a85ee4386ad29c60a185af8a7861a9c2b9404d29 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 22:49:47 +0200 Subject: [PATCH 3/6] gnu/rm: make the code reentrant --- util/build-gnu.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index c575e84f6..cd0f7dc39 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -59,7 +59,7 @@ do done -grep -rl 'path_prepend_' tests/* | xargs sed -i 's|path_prepend_ ./src||' +grep -rl 'path_prepend_' tests/* | xargs sed -i 's| path_prepend_ ./src||' sed -i -e 's|^seq |/usr/bin/seq |' -e 's|sha1sum |/usr/bin/sha1sum |' tests/factor/t*sh # Remove tests checking for --version & --help @@ -94,11 +94,14 @@ sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh sed -i 's|seq |/usr/bin/seq |' tests/misc/sort-discrim.sh -#Add specific timeout to tests that currently hang to limit time spent waiting +# Add specific timeout to tests that currently hang to limit time spent waiting sed -i 's|seq \$|/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh sed -i 's|cat |/usr/bin/timeout 0.1 cat |' tests/misc/cat-self.sh +# Remove dup of /usr/bin/ when executed several times +grep -rl '/usr/bin//usr/bin/' tests/* | xargs --no-run-if-empty sed -i 's|/usr/bin//usr/bin/|/usr/bin/|g' + #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) From 9cf3ab894f0a887d5085fdf08abb52a13d3acb07 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 23:00:51 +0200 Subject: [PATCH 4/6] gnu/ci: build in parallel --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index cd0f7dc39..0c511ffab 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -44,7 +44,7 @@ sed -i 's|"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${BUILDDIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile sed -i 's| tr | /usr/bin/tr |' tests/init.sh -make +make -j "$(nproc)" # Generate the factor tests, so they can be fixed # Used to be 36. Reduced to 20 to decrease the log size for i in {00..20} From aabef14404274a7071dad8725ba7b51019b31c3b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 23:07:51 +0200 Subject: [PATCH 5/6] gnu/rm: fix tests/rm/cycle.sh --- util/build-gnu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 0c511ffab..691598881 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -110,4 +110,6 @@ grep -rl '/usr/bin//usr/bin/' tests/* | xargs --no-run-if-empty sed -i 's|/usr/b sed -i -e "s|rm: cannot remove 'e/slink'|rm: cannot remove 'e'|g" tests/rm/fail-eacces.sh +sed -i -e "s|rm: cannot remove 'a/b/file'|rm: cannot remove 'a'|g" tests/rm/cycle.sh + test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" From f421e51ad3df3b796ebf2d03ff8e099a1919ac93 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 3 Jun 2021 23:30:33 +0200 Subject: [PATCH 6/6] gnu/rm: fix tests/rm/rm{1,2}.sh --- util/build-gnu.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 691598881..83136e733 100644 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -112,4 +112,8 @@ sed -i -e "s|rm: cannot remove 'e/slink'|rm: cannot remove 'e'|g" tests/rm/fail- sed -i -e "s|rm: cannot remove 'a/b/file'|rm: cannot remove 'a'|g" tests/rm/cycle.sh +sed -i -e "s|rm: cannot remove directory 'b/a/p'|rm: cannot remove 'b'|g" tests/rm/rm1.sh + +sed -i -e "s|rm: cannot remove 'a/1'|rm: cannot remove 'a'|g" tests/rm/rm2.sh + test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}"