Re: [PATCH] tests: fix py-compile-basedir.sh: add missing test call
On 18 Jan 2022 11:29, Jim Meyering wrote: > On Tue, Jan 18, 2022 at 10:29 AM Mike Frysinger wrote: > > On 18 Jan 2022 09:48, Jim Meyering wrote: > ... > > > But IMHO that's too much duplication/syntax. > > > How about this instead? > > > > > > case $(echo "$files" | wc -l) in 4|6) ;; *) false;; esac > > > > looks reasonable for POSIX shell. not a fan of the one-line, but that style > > seems to be SOP for test code, so i won't whine too loudly :p. > > > > i assume you'll take care of writing the actual patch at this point since it > > was your idea ? :) > > Sure. How about this? lgtm, thanks -mike signature.asc Description: PGP signature
Re: [PATCH] tests: fix py-compile-basedir.sh: add missing test call
On Tue, Jan 18, 2022 at 10:29 AM Mike Frysinger wrote: > On 18 Jan 2022 09:48, Jim Meyering wrote: ... > > But IMHO that's too much duplication/syntax. > > How about this instead? > > > > case $(echo "$files" | wc -l) in 4|6) ;; *) false;; esac > > looks reasonable for POSIX shell. not a fan of the one-line, but that style > seems to be SOP for test code, so i won't whine too loudly :p. > > i assume you'll take care of writing the actual patch at this point since it > was your idea ? :) Sure. How about this? From: Jim Meyering Date: Tue, 18 Jan 2022 02:00:22 -0800 Subject: [PATCH] tests: fix py-compile-basedir.sh: missing "test" Prompted by a patch from Thomas Deutschmann , via https://lists.gnu.org/r/automake-patches/2022-01/msg1.html: commit v1.16.1-26-gb279a0d46 ("tests: in python tests, do not require .pyo files (for python3)") was missing a `test` call. Reported to Gentoo at https://bugs.gentoo.org/715040. * t/py-compile-basedir.sh: Rather than just adding the missing "test", rewrite using a case statement, to avoid some duplication. --- t/py-compile-basedir.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh index 44b6b07c1..22e605f9d 100644 --- a/t/py-compile-basedir.sh +++ b/t/py-compile-basedir.sh @@ -43,7 +43,7 @@ for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do py_installed "$d2/sub/$f.pyc" files=$(find "$d2" | grep '\.py[co]$') # with new-enough Python3, there are six files. - test $(echo "$files" | wc -l) -eq 4 || $(echo "$files" | wc -l) -eq 6 + case $(echo "$files" | wc -l) in 4|6) ;; *) false;; esac case $d2 in .|..) rm -f $files;; *) rm -rf "$d2";; --
Re: [PATCH] tests: fix py-compile-basedir.sh: add missing test call
On 18 Jan 2022 09:48, Jim Meyering wrote: > On Tue, Jan 18, 2022 at 7:46 AM Mike Frysinger wrote: > > From: Thomas Deutschmann > > > > Commit b279a0d46dfeca1ca40057c3c910ab1657d60be5 ("tests: in python > > tests, do not require .pyo files (for python3)") had a slight logic > > error in that it missed a `test` call. > > > > Reported to Gentoo at https://bugs.gentoo.org/715040. > > > > * t/py-compile-basedir.sh: Add test command. > > --- > > t/py-compile-basedir.sh | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh > > index 44b6b07c1962..979f65710c0b 100644 > > --- a/t/py-compile-basedir.sh > > +++ b/t/py-compile-basedir.sh > > @@ -43,7 +43,7 @@ for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do > >py_installed "$d2/sub/$f.pyc" > >files=$(find "$d2" | grep '\.py[co]$') > ># with new-enough Python3, there are six files. > > - test $(echo "$files" | wc -l) -eq 4 || $(echo "$files" | wc -l) -eq 6 > > + test $(echo "$files" | wc -l) -eq 4 || test $(echo "$files" | wc -l) -eq > > 6 > > Thanks. Good catch. > If we were to use that, it's a little better to double-quote each > $(...) result, in case somehow the result is not just precisely one > token: > > test "$(echo "$files" | wc -l)" -eq 4 || test "$(echo "$files" | wc -l)" > -eq 6 > > But IMHO that's too much duplication/syntax. > How about this instead? > > case $(echo "$files" | wc -l) in 4|6) ;; *) false;; esac looks reasonable for POSIX shell. not a fan of the one-line, but that style seems to be SOP for test code, so i won't whine too loudly :p. i assume you'll take care of writing the actual patch at this point since it was your idea ? :) -mike signature.asc Description: PGP signature
Re: [PATCH] tests: fix py-compile-basedir.sh: add missing test call
On Tue, Jan 18, 2022 at 7:46 AM Mike Frysinger wrote: > From: Thomas Deutschmann > > Commit b279a0d46dfeca1ca40057c3c910ab1657d60be5 ("tests: in python > tests, do not require .pyo files (for python3)") had a slight logic > error in that it missed a `test` call. > > Reported to Gentoo at https://bugs.gentoo.org/715040. > > * t/py-compile-basedir.sh: Add test command. > --- > t/py-compile-basedir.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh > index 44b6b07c1962..979f65710c0b 100644 > --- a/t/py-compile-basedir.sh > +++ b/t/py-compile-basedir.sh > @@ -43,7 +43,7 @@ for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do >py_installed "$d2/sub/$f.pyc" >files=$(find "$d2" | grep '\.py[co]$') ># with new-enough Python3, there are six files. > - test $(echo "$files" | wc -l) -eq 4 || $(echo "$files" | wc -l) -eq 6 > + test $(echo "$files" | wc -l) -eq 4 || test $(echo "$files" | wc -l) -eq 6 Thanks. Good catch. If we were to use that, it's a little better to double-quote each $(...) result, in case somehow the result is not just precisely one token: test "$(echo "$files" | wc -l)" -eq 4 || test "$(echo "$files" | wc -l)" -eq 6 But IMHO that's too much duplication/syntax. How about this instead? case $(echo "$files" | wc -l) in 4|6) ;; *) false;; esac
[PATCH] tests: fix py-compile-basedir.sh: add missing test call
From: Thomas Deutschmann Commit b279a0d46dfeca1ca40057c3c910ab1657d60be5 ("tests: in python tests, do not require .pyo files (for python3)") had a slight logic error in that it missed a `test` call. Reported to Gentoo at https://bugs.gentoo.org/715040. * t/py-compile-basedir.sh: Add test command. --- t/py-compile-basedir.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh index 44b6b07c1962..979f65710c0b 100644 --- a/t/py-compile-basedir.sh +++ b/t/py-compile-basedir.sh @@ -43,7 +43,7 @@ for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do py_installed "$d2/sub/$f.pyc" files=$(find "$d2" | grep '\.py[co]$') # with new-enough Python3, there are six files. - test $(echo "$files" | wc -l) -eq 4 || $(echo "$files" | wc -l) -eq 6 + test $(echo "$files" | wc -l) -eq 4 || test $(echo "$files" | wc -l) -eq 6 case $d2 in .|..) rm -f $files;; *) rm -rf "$d2";; -- 2.33.0