Hi Frederic and all - I pushed the following tweaks to a few
tests. With these changes, I was able to run make distcheck with
SOURCE_DATE_EPOCH=86402 (among other values). Hope it suffices
.. --thanks, karl. (And thanks Carlos for the info.)

-----------------------------------------------------------------------------
test: adapt tests for SOURCE_DATE_EPOCH.

>From https://lists.gnu.org/archive/html/automake/2025-06/msg00016.html.

* t/mdate5.sh: allow years 19xx for old SOURCE_DATE_EPOCH.
* t/txinfo-vtexi3.sh: likewise.
* t/txinfo-vtexi4.sh: if SDE is set, use mdate-sh to parse it into
the expected UPDATED and UPDATED-MONTH values.
Report from Frederic Berat.
* NEWS: mention this.
diff --git a/NEWS b/NEWS
index 02581e1d9..ac1930971 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 For planned incompatibilities in a possible future Automake 2.0 release,
 please see NEWS-future and start following the advice there now.

+* Bugs fixed
+
+  - Keep Automake tests working when SOURCE_DATE_EPOCH is set.
+  (https://lists.gnu.org/archive/html/automake/2025-06/msg00016.html)
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 New in 1.18 (2025-05-25):

diff --git a/t/mdate5.sh b/t/mdate5.sh
index 11be50f13..14c524e9b 100644
--- a/t/mdate5.sh
+++ b/t/mdate5.sh
@@ -29,16 +29,22 @@ echo "$*" # For debugging.
 test $# = 3
 case $1$3 in *[!0-9]*) exit 1;; esac
 test $1 -lt 32
-# Hopefully automake will be obsolete in 80 years ;-)
-case $3 in 20[0-9][0-9]) :;; *) exit 1;; esac
+case $3 in
+  19[0-9][0-9]) :;; # for old SOURCE_DATE_EPOCH.
+  20[0-9][0-9]) :;; # Hopefully automake will be obsolete in 80 years ;-)
+  *) exit 1;;
+esac
 case $2 in
   January|February|March|April|May|June|July|August) ;;
   September|October|November|December) ;;
   *) exit 1
 esac

-# Stricter checks on the year required a POSIX date(1) command.
-if year=$(date +%Y) && test $year -gt 2010; then
+# Stricter checks on the year required a POSIX date(1) command,
+# and that SOURCE_DATE_EPOCH is not set.
+if year=$(date +%Y) \
+   && test -z "$SOURCE_DATE_EPOCH" \
+   && test $year -gt 2010; then
   test $year = $3 || exit 1
 fi

diff --git a/t/txinfo-vtexi3.sh b/t/txinfo-vtexi3.sh
index d5ca81679..1c91fc547 100644
--- a/t/txinfo-vtexi3.sh
+++ b/t/txinfo-vtexi3.sh
@@ -73,7 +73,9 @@ $AUTOMAKE

 day='([1-9]|1[0-9]|2[0-9]|3[01])'
 
month='(January|February|March|April|May|June|July|August|September|October|November|December)'
-year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
+year='(20|19)[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
+                         # Allow 19xx for SOURCE_DATE_EPOCH possibilities.
+#
 date="$day $month $year"

 do_check ()
diff --git a/t/txinfo-vtexi4.sh b/t/txinfo-vtexi4.sh
index 1c76abda7..a69cc46f2 100644
--- a/t/txinfo-vtexi4.sh
+++ b/t/txinfo-vtexi4.sh
@@ -28,11 +28,22 @@ required='makeinfo tex texi2dvi grep-nonprint'
 # differ depending on local time.
 TZ=UTC0; export TZ

-test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \
-  && day=$(LC_ALL=C date '+%d')   && test -n "$day" \
-  && month=$(LC_ALL=C date '+%B') && test -n "$month" \
-  && year=$(LC_ALL=C date '+%Y')  && test -n "$year" \
-  || skip_ "'date' is not POSIX-compliant enough"
+if test -n "$SOURCE_DATE_EPOCH"; then
+  # use mdate-sh to parse SOURCE_DATE_EPOCH.
+  get_shell_script mdate-sh
+  result=`mdate-sh /irrelevant`
+  echo "result of mdate-sh: $result"
+  day=`echo $result | awk '{print $1}'`
+  month=`echo $result | awk '{print $2}'`
+  year=`echo $result | awk '{print $3}'`
+else
+  test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \
+    && day=$(LC_ALL=C date '+%d')   && test -n "$day" \
+    && month=$(LC_ALL=C date '+%B') && test -n "$month" \
+    && year=$(LC_ALL=C date '+%Y')  && test -n "$year" \
+    || skip_ "'date' is not POSIX-compliant enough"
+fi
+#
 day=$(echo "$day" | sed 's/^0//')

 cat > configure.ac << END

compile finished at Fri Jun 20 09:04:52 2025


Reply via email to