]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
test: adapt tests for SOURCE_DATE_EPOCH.
authorKarl Berry <karl@freefriends.org>
Fri, 20 Jun 2025 16:04:52 +0000 (09:04 -0700)
committerKarl Berry <karl@freefriends.org>
Fri, 20 Jun 2025 16:04:52 +0000 (09:04 -0700)
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.

NEWS
t/mdate5.sh
t/txinfo-vtexi3.sh
t/txinfo-vtexi4.sh

diff --git a/NEWS b/NEWS
index 02581e1d91003a0b29111d69647896a4a62751cc..ac193097133079ca471d7060d64c8d91544095da 100644 (file)
--- 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):
 
index 11be50f13fbd521cade399ca63e4e1de68527653..14c524e9b84c52d4187a29e9afceb8774af02ff9 100644 (file)
@@ -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
 
index d5ca81679695eb4763bdc431d7ff3b4ae153457c..1c91fc5475f1d3f870e4892fda8fc66428b781c5 100644 (file)
@@ -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 ()
index 1c76abda721dec310b52d9089cfbca61239f93f0..a69cc46f24b9fac4c64325fc37d70126cef0904c 100644 (file)
@@ -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