]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix test failure on macOS 15.1.1
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 1 Jan 2025 21:30:26 +0000 (13:30 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 1 Jan 2025 21:30:49 +0000 (13:30 -0800)
Problem reported by Sean Denny in:
https://lists.gnu.org/r/bug-autoconf/2024-12/msg00001.html
* doc/autoconf.texi (Limitations of Builtins):
Document the macOS sh bug.
* tests/base.at (AC_CACHE_CHECK):
* tests/local.at: Use test -ot rather than ls -t, as POSIX
requires the former to work reliably, but does not require the
latter (POSIX does not require a stable sort for ls -t).
Somewhat ironically, this should work around the macOS bug
because the use of its buggy test -ot should increase the
timestamp resolution to 1 s.

doc/autoconf.texi
tests/base.at
tests/local.at

index 4f2a68ad79413ced467bc9af56178f0dbd945683..9d2c2d0d85ea9889fa11507b7541774e18e4bdb4 100644 (file)
@@ -18532,10 +18532,18 @@ the host system.  But occasionally you may find it necessary to check
 whether some arbitrary file exists.  To do so, use @samp{test -f},
 @samp{test -r}, or @samp{test -x}.  Do not use @samp{test -e}, because
 Solaris 10 @command{/bin/sh}
-lacks it.  To test for symbolic links on systems that have them, use
+lacks it.
+
+To test for symbolic links on systems that have them, use
 @samp{test -h} rather than @samp{test -L}; either form conforms to
 POSIX 1003.1-2001, but @option{-h} has been around longer.
 
+The commands @samp{test A -ot B} and @samp{test A -nt B} are not reliable
+on macOS @command{sh} through at least macOS Sequoia 15.1.1 (2024),
+where @samp{test} ignores the subsecond part of file timestamps.
+To work around this bug, arrange for the timestamps to be at least one
+second apart.
+
 For historical reasons, POSIX reluctantly allows implementations of
 @samp{test -x} that will succeed for the root user, even if no execute
 permissions are present.  Furthermore, shells do not all agree on
index 7b8bb32cdf9837c9de853a842c51d5abb1259211..5ef3d9e46499ac7d58d2c566c942bf183bb61f44 100644 (file)
@@ -729,7 +729,7 @@ AT_CHECK([grep cache stdout], [0], [ignore])
 : > a-stamp-file
 AT_CHECK_CONFIGURE([], [], [stdout])
 AT_CHECK([grep cache stdout], [1])
-AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1])
+AT_CHECK([test config.cache -ot a-stamp-file])
 
 # Using a symlinked cache file works.
 : > cache
index 9193199c8aa78d5fc2b45bd8414c483b2d0529a4..6bf31ab328f62d57875b281a14d89103d94abe4c 100644 (file)
@@ -137,10 +137,7 @@ then
 fi
 
 # In order to catch current-generation FAT out, we must *modify* files
-# that already exist; the *creation* timestamp is finer.  Use names
-# that make ls -t sort them differently when they have equal
-# timestamps than when they have distinct timestamps, keeping
-# in mind that ls -t prints the *newest* file first.
+# that already exist; the *creation* timestamp is finer.
 rm -f conftest.ts?
 : > conftest.ts1
 : > conftest.ts2
@@ -157,12 +154,8 @@ for at_try_res in $at_try_resolutions; do
   sleep $at_try_res
   echo gamma > conftest.ts3
 
-  # We assume that 'ls -t' will make use of high-resolution
-  # timestamps if the operating system supports them at all.
-  set X `ls -t conftest.ts?`
-  if test "$[]2" = conftest.ts3 &&
-     test "$[]3" = conftest.ts2 &&
-     test "$[]4" = conftest.ts1; then
+  if test conftest.ts1 -ot conftest.ts2 &&
+     test conftest.ts2 -ot conftest.ts3; then
     at_ts_resolution=$at_try_res
     break
   fi