[bug#60807] [PATCH v2] tests: reuse am_cv_filesystem_timestamp_resolution
Jacob Bachmeyer <[email protected]> Sat, 14 Jan 2023 21:43:13 -0600
| Newsgroups | gmane.comp.sysutils.automake.patches |
|---|---|
| Message-ID | <[email protected]> |
Mike Frysinger wrote:
> Rather than assume such coarse delays, re-use existing logic for
> probing the current filesystem resolution. This speeds up the
> testsuite significantly. On my system, it speeds -j1 up quite a
> lot -- by ~30%. While I didn't gather many samples to produce a
> statistically significant distribution, my runs seem to be fairly
> consistent with the values below with deviations of <1 minute.
>
> [...]
> diff --git a/t/aclocal-no-force.sh b/t/aclocal-no-force.sh
> index 3e0c04d12f18..2e139d75cf74 100644
> --- 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
> +
> cat >> configure.ac << 'END'
> SOME_DEFS
> AC_CONFIG_FILES([sub/Makefile])
>
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?
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.
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".)
-- Jacob