[bug#59990] [PATCH] tests: depcomp: ensure make_ok() fails when run_make fails

2023-01-15 Thread Mike Frysinger
thanks, lgtm, merged
-mike





[bug#60829] [PATCH] m4: use AS_IF to avoid ! portability issues

2023-01-15 Thread Mike Frysinger
Since the ! builtin has portability issues (as documented in the Autoconf
manual), switch to AS_IF which takes care of these issues for us.

* m4/sanity.m4: Switch `if` to AS_IF.
---
 m4/sanity.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/m4/sanity.m4 b/m4/sanity.m4
index db9a1f5639f1..c24648045e2f 100644
--- a/m4/sanity.m4
+++ b/m4/sanity.m4
@@ -110,10 +110,10 @@ fi
 # If we didn't sleep, we still need to ensure time stamps of config.status and
 # generated files are strictly newer.
 am_sleep_pid=
-if ! test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1; 
then
+AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 
2>&1],, [dnl
   ( sleep $am_cv_filesystem_timestamp_resolution ) &
   am_sleep_pid=$!
-fi
+])
 AC_CONFIG_COMMANDS_PRE(
   [AC_MSG_CHECKING([that generated files are newer than configure])
if test -n "$am_sleep_pid"; then
-- 
2.39.0






[bug#60807] [PATCH 1/2] mtime: use Time::HiRes::stat when available for subsecond resolution

2023-01-15 Thread Mike Frysinger
On 14 Jan 2023 21:27, Jacob Bachmeyer wrote:
> Mike Frysinger wrote:
> > --- a/lib/Automake/FileUtils.pm
> > +++ b/lib/Automake/FileUtils.pm
> > @@ -42,6 +42,11 @@ use Exporter;
> >  use File::stat;
> >  use IO::File;
> >  
> > +# Perl's builtin stat does not provide sub-second resolution.  Use 
> > Time::HiRes
> > +# if it's available instead.  Hopefully one day perl will update.
> > +# https://github.com/Perl/perl5/issues/17900
> > +my $have_time_hires = eval { require Time::HiRes; };
> > +
> >  use Automake::Channels;
> >  use Automake::ChannelDefs;
> >  
> > @@ -115,10 +120,18 @@ sub mtime ($)
> >return 0
> >  if $file eq '-' || ! -f $file;
> >  
> > -  my $stat = stat ($file)
> > -or fatal "cannot stat $file: $!";
> > -
> > -  return $stat->mtime;
> > +  if ($have_time_hires)
> > +{
> > +  my @stat = Time::HiRes::stat ($file)
> > +   or fatal "cannot stat $file: $!";
> > +  return $stat[9];
> > +}
> > +  else
> > +{
> > +  my $stat = stat ($file)
> > +   or fatal "cannot stat $file: $!";
> > +  return $stat->mtime;
> > +}
> >  }
> 
> If you change that variable to a constant, you can eliminate the runtime 
> overhead entirely, since Perl optimizes if(1) and if(0) and folds 
> constants at compile time.
> 
> Something like:
> 
> use constant HAVE_Time_HiRes => eval { require Time::HiRes; };
> 
> Then:
> 
> if (HAVE_Time_HiRes)
>...
> 
> If you do this, Perl will inline the block actually used and elide the 
> branch at runtime.  This is generally useful for any test that can only 
> go one way in a specific run of the program.

thanks, i'll integrate that idea.  i'm by no means a perl programmer.
-mike


signature.asc
Description: PGP signature


[bug#60807] [PATCH v2] tests: reuse am_cv_filesystem_timestamp_resolution

2023-01-15 Thread Mike Frysinger
On 14 Jan 2023 21:43, Jacob Bachmeyer wrote:
> Mike Frysinger wrote:
> > --- a/t/aclocal-no-force.sh
> > +++ b/t/aclocal-no-force.sh
> > @@ -19,6 +19,18 @@
> >  
> >  . test-init.sh
> >  
> > +# Automake relies on high resolution timestamps in perl.  If support isn't
> > +# available (see lib/Automake/FileUtils.pm), then fallback to coarse 
> > sleeps.
> > +# The creative quoting is to avoid spuriously triggering a failure in
> > +# the maintainer checks.
> > +case ${sleep_delay} in
> > +0*)
> > +  if ! $PERL -e 'use Time::HiRes' 2>/dev/null; then
> > +sleep='sleep ''2'
> > +  fi
> > +  ;;
> > +esac
> > +
> 
> I seem to remember being told that "if !" is non-portable.  Is there 
> some other mechanism that ensures this is always run with Bash or might 
> "if $PERL ... ; then :; else" be a better option for that line?

you're right:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/Limitations-of-Builtins.html

i'll note that Automake tests have been using `if ! ...` since 1.12 (2012),
and no one seems to have complained.  further, the shell we're using here is
the one autoconf and/or we detected, so it should avoid older broken ones.
i'm inclined to not bend over backwards for this.

> Also, you could write that Perl command as "$PERL -MTime::HiRes -e 1 
> 2>/dev/null" and avoid needing any quotes there, although I suspect this 
> is simply a matter of style and the comment refers to the quotes when 
> setting $sleep.

yes, the quoting comment is referring to the sleep statement.  i can clarify
in the comment by referring to "sleep".

> You could also exploit that || short-circuits in the shell and replace 
> the "if" block with " $PERL ... || sleep='sleep ''2' ".  This allows you 
> to directly execute a command on a false result and (I think) it is 
> portable, too.  (I half-expect someone to correct me on that along the 
> lines of "the shell on Obscurix has a bug where || implicitly uses a 
> subshell".)

personally i find (ab)use of `||` and `&&` tends to lead to unmaintainable code.
i.e. it tends to produce write-once-read-never code akin to most perl.  so if
the construct has been in use already and isn't causing issues, i'd use it.
-mike


signature.asc
Description: PGP signature