]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
tests: New helper macro AT_CHECK_MAKE.
authorZack Weinberg <zackw@panix.com>
Thu, 20 Aug 2020 15:04:20 +0000 (11:04 -0400)
committerZack Weinberg <zackw@panix.com>
Thu, 20 Aug 2020 18:07:59 +0000 (14:07 -0400)
This macro factors out some repeated code surrounding tests that run
make, such as honoring $MAKE, *not* honoring $MAKEFLAGS, and
normalizing the exit status.  Partially addresses bug #110267
(problems with Sun’s make barfing on GNU make options from
$MAKEFLAGS).

Also addresses some unrelated problems I noticed while changing all
the tests that run make to use this macro:

The shtool test is now properly skipped if shtool is not available on
the host system.

Some of the Fortran tests would create an executable and then run it,
others would create an executable and then the AT_CHECK operation that
would run it was commented out.  There’s no evidence in the changelog
or the git history for why this was done.  I uncommented all of the
commented-out cases; this can be undone easily if it causes
problems.  (It can’t be an issue with cross-compilation because some
of the tests do run the executable.)

* tests/local.at (AT_CHECK_MAKE): New macro wrapping an AT_CHECK
  invocation of make.  All tests that run make updated to use this macro.
* tests/fortran.at: Uncomment all AT_CHECKs that run the just-compiled
  program.
* tests/foreign.at (shtool): Skip the test if shtool is not available
  from the host system.  Simplify shell logic.

tests/autotest.at
tests/c.at
tests/foreign.at
tests/fortran.at
tests/local.at
tests/torture.at

index 5519e9c7b5ced0b2c608abaa51faad893cfbcf4a..2892b1dd111b31dbf276c4fe7b4ab4c354d4d397 100644 (file)
@@ -1599,20 +1599,13 @@ for signal in 2 15; do
   # AT_CHECK([[grep '[iI]nterrupt[      ]' stderr]], [1])
 
   # Ditto with `make' in the loop.
-  : "${MAKE=make}"
-  unset MAKEFLAGS
-  # Need to eliminate outer TESTSUITEFLAGS here.
-  # Need to normalize exit status here: some make implementations
-  # exit 1 (BSD make), some exit 2 (GNU make).
-  AT_CHECK([$MAKE check TESTSUITEFLAGS=; ]dnl
-          [case $? in 1|2) exit 1;; *) exit $?;; esac],
-          [1], [ignore], [stderr])
+  # Explicitly setting TESTSUITEFLAGS to empty...
+  AT_CHECK_MAKE([TESTSUITEFLAGS=], [], [1], [ignore], [stderr])
   AT_CHECK([grep 'bailing out' stderr], [], [ignore])
   AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
-  # Ditto, parallel case.
-  AT_CHECK([$MAKE check TESTSUITEFLAGS=--jobs=3; ]dnl
-          [case $? in 1|2) exit 1;; *) exit $?;; esac],
-          [1], [ignore], [stderr])
+
+  # ... and explicitly requesting 3-fold parallelism.
+  AT_CHECK_MAKE([TESTSUITEFLAGS=--jobs=3], [], [1], [ignore], [stderr])
   AT_CHECK([grep 'bailing out' stderr], [], [ignore])
   AT_CHECK([grep 'bailing out' micro-suite.log], [], [ignore])
 done
@@ -1926,7 +1919,7 @@ rm t/atconfig
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
 AT_CHECK([grep '^EXEEXT='\''.*'\' t/atconfig], [], [ignore])
-AT_CHECK([${MAKE-make}], [], [ignore])
+AT_CHECK_MAKE
 AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
 AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
 AT_CLEANUP
@@ -1978,7 +1971,7 @@ rm t/atconfig
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
 AT_CHECK([grep '^EXEEXT='\''.*'\' t/atconfig], [], [ignore])
-AT_CHECK([${MAKE-make}], [], [ignore])
+AT_CHECK_MAKE
 AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
 AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
 AT_CLEANUP
index b1dabd14acde03944aa280e651a8a869ba0b7df5..d13b321e892093ac1056ca7f7cea7ab582e2da19 100644 (file)
@@ -326,11 +326,11 @@ class foo { int x; };
 class foo foobar;
 ]])
 
-AT_CHECK([autoconf])
-AT_CHECK([autoheader])
-AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
-AT_CHECK([${MAKE-make} cpp-works || exit 77], [], [ignore], [ignore])
-AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER([], [restrict])
+AT_CHECK_CONFIGURE
+AT_CHECK_MAKE([cpp-works || exit 77])
+AT_CHECK_MAKE
 
 AT_CLEANUP
 
@@ -381,10 +381,9 @@ int main (void)
 }
 ]])
 
-: "${MAKE=make}"
-AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
-AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK_MAKE
 
 AT_CLEANUP
 
@@ -424,9 +423,8 @@ AT_DATA([foo.cpp],
 }
 ]])
 
-: "${MAKE=make}"
-AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
-AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK_MAKE
 
 AT_CLEANUP
index d8280743a81922111d3585d9460094a78f7b8de3..7a49333a35fbae487e851e7ee7c03d9dec78a9f7 100644 (file)
@@ -122,20 +122,22 @@ copy-shtool:
 : >file1
 : >file2
 chmod +x file1
-: "${MAKE=make}"
 mkdir build-aux inst
 instdir=`pwd`/inst
 AT_CHECK_AUTOCONF
 cp "$abs_top_srcdir/build-aux/install-sh" build-aux
 AT_CHECK_CONFIGURE
-AT_CHECK([$MAKE copy-shtool], [], [ignore], [ignore],
-        [AT_CHECK([: >build-aux/shtool])])
+AT_SKIP_IF([grep 'SHTOOL = false' Makefile > /dev/null 2>&1])
+
+AT_CHECK_MAKE([copy-shtool])
+AT_CHECK([test -s build-aux/shtool])
+
+# AC_PROG_INSTALL should pick up shtool from build-aux, even though
+# we're forcing AC_PATH_PROG not to find it on the host system.
 rm -f build-aux/install-sh
 AT_CHECK_CONFIGURE([--prefix="$instdir" ac_cv_path_SHTOOL=false])
 AT_CHECK([grep '^ac_install_sh = .*shtool install -c' Makefile], [], [ignore])
-if test -s build-aux/shtool; then
-  AT_CHECK([$MAKE install], [], [ignore], [ignore])
-  AT_CHECK([test -f inst/file1 && test -f inst/file2 && test -x inst/file1])
-fi
+AT_CHECK_MAKE([install])
+AT_CHECK([test -f inst/file1 && test -f inst/file2 && test -x inst/file1])
 
 AT_CLEANUP
index 241d9b0d32b69ce31000e2a00d8b79885b608953..cf4d9fef517493c3a9e8384d9f810fe71bc2aa9f 100644 (file)
@@ -109,10 +109,9 @@ AT_DATA([foo.f],
       end
 ]])
 
-: "${MAKE=make}"
 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
 AT_CHECK_CONFIGURE
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE
 
 AT_CLEANUP
 
@@ -149,10 +148,9 @@ AT_DATA([foo.f],
       end
 ]])
 
-: "${MAKE=make}"
 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
 AT_CHECK_CONFIGURE
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE
 
 AT_CLEANUP
 
@@ -244,9 +242,8 @@ AT_CHECK_AUTOHEADER([], [
   FC_DUMMY_MAIN_EQ_F77
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram])
 
 AT_CLEANUP
 
@@ -327,9 +324,8 @@ AT_CHECK_AUTOHEADER([], [
   FC_FUNC_
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram])
 
 AT_CLEANUP
 
@@ -409,12 +405,11 @@ AT_CHECK_AUTOHEADER([], [
   FC_DUMMY_MAIN_EQ_F77
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram], [], [output from C main
-dnl  some output from Fortran sources
-dnl more output from C main
-dnl ])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram], [], [output from C main
+ some output from Fortran sources
+more output from C main
+])
 
 AT_CLEANUP
 
@@ -494,12 +489,11 @@ AT_CHECK_AUTOHEADER([], [
   FC_MAIN
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram], [], [output from C main
-dnl  some output from Fortran sources
-dnl more output from C main
-dnl ])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram], [], [output from C main
+ some output from Fortran sources
+more output from C main
+])
 
 AT_CLEANUP
 
@@ -574,9 +568,8 @@ AT_CHECK_AUTOHEADER([], [
   FC_DUMMY_MAIN_EQ_F77
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram])
 
 AT_CLEANUP
 
@@ -651,9 +644,9 @@ AT_CHECK_AUTOHEADER([], [
   FC_DUMMY_MAIN_EQ_F77
 ])
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./cprogram])
+AT_CHECK_MAKE
+AT_CHECK([./cprogram])
+
 AT_CLEANUP
 
 
@@ -736,8 +729,7 @@ end
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE
 
 AT_CLEANUP
 
@@ -836,8 +828,8 @@ this is not correct fortran
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE
+AT_CHECK([./prog])
 
 AT_CLEANUP
 
@@ -872,9 +864,8 @@ end
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./prog])
+AT_CHECK_MAKE
+AT_CHECK([./prog])
 
 AT_CLEANUP
 
@@ -910,9 +901,8 @@ end
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./prog])
+AT_CHECK_MAKE
+AT_CHECK([./prog])
 
 AT_CLEANUP
 
@@ -948,9 +938,8 @@ C      fixed-form style comment
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./prog])
+AT_CHECK_MAKE
+AT_CHECK([./prog])
 
 AT_CLEANUP
 
@@ -987,9 +976,8 @@ C      fixed-form style comment
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
-dnl AT_CHECK([./prog])
+AT_CHECK_MAKE
+AT_CHECK([./prog])
 
 AT_CLEANUP
 
@@ -1056,10 +1044,9 @@ EOF
 
     AT_CHECK_AUTOCONF
     AT_CHECK_CONFIGURE
-    : "${MAKE=make}"
-    AT_CHECK([$MAKE], [], [ignore], [ignore])
-    dnl AT_CHECK([./prog])
-    AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+    AT_CHECK_MAKE
+    AT_CHECK([./prog])
+    AT_CHECK_MAKE([clean])
 
   done
 done
@@ -1118,10 +1105,9 @@ AT_DATA([prog.f],
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE
 AT_CHECK([./prog || exit 1], [1], [ignore], [ignore])
-AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+AT_CHECK_MAKE([clean])
 
 AT_CLEANUP
 
@@ -1186,12 +1172,11 @@ AT_DATA([prog.f],
 
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-: "${MAKE=make}"
-AT_CHECK([$MAKE], [], [stdout], [stderr])
+AT_CHECK_MAKE([], [], [], [stdout], [stderr])
 # Both the FCFLAGS setting from configure.ac, and the Makefile rule
 # should add to the module search path.
 AT_CHECK([grep 'sub .*sub ' stdout stderr], [], [ignore])
 AT_CHECK([./prog], [], [ignore], [ignore])
-AT_CHECK([$MAKE clean], [], [ignore], [ignore])
+AT_CHECK_MAKE([clean])
 
 AT_CLEANUP
index d667d630a4604a2afa410de9e030b5ba35420459..0fe1c343830376a9c411fdda56a4bf389520af7a 100644 (file)
@@ -479,6 +479,31 @@ m4_define([AT_CHECK_AUTOUPDATE],
 ])
 
 
+# AT_CHECK_MAKE(MAKEARGS, DIRECTORY, EXIT-STATUS,
+#               [STDOUT = IGNORE], [STDERR = IGNORE])
+# ---------------------------------------------------------------
+# Run make in DIRECTORY (default `.'), passing MAKEARGS on the command
+# line.  EXIT-STATUS, STDOUT, and STDERR are as for AT_CHECK.
+# The environment variable MAKE is honored if present.
+# The environment variable MAKEFLAGS is *cleared*.
+# If EXIT-STATUS is 1, an exit status of either 1 or 2 is considered
+# an acceptable result, because there are situations where BSD make will
+# exit with status 1 but GNU make will instead exit with status 2.
+m4_define([AT_CHECK_MAKE],
+[: "${MAKE=make}"
+export MAKE
+unset MAKEFLAGS
+AT_CHECK(
+  m4_if(m4_default([$2], [.]), [.], [],
+        [cd "$2" && ])[$][MAKE]m4_ifnblank([$1],[ $1])[]m4_if([$3], [1], [[
+dnl pacify editors that don't understand sh case: ((
+  case $? in 1|2) exit 1;; *) exit $?;; esac]]),
+  [$3],
+  m4_default([$4], [ignore]),
+  m4_default([$5], [ignore]))
+])
+
+
 # _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
 # --------------------------------------
 # Create a minimalist configure.ac running the macro named
index 37deef25bbcffa114e212622f33935db51b777fb..616e051c494f70592c99b24ba5969a13a89a971e 100644 (file)
@@ -1248,14 +1248,12 @@ all: f f1 f2
 
 AT_CHECK_AUTOCONF
 
-: "${MAKE=make}"
-
 # In place.
 AT_CHECK([./configure $configure_options], [], [ignore])
 # Treat BSD make separately, afterwards, for maximal coverage.
 dirs='at paren brace'
 for dir in $dirs; do
-  AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
+  AT_CHECK_MAKE([], [$dir])
 done
 
 rm -f config.status
@@ -1264,20 +1262,21 @@ mkdir build absbuild
 # Relative name.
 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
 for dir in $dirs; do
-  AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
+  AT_CHECK_MAKE([], [build/$dir])
 done
 
 # Absolute name.
 at_here=`pwd`
 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
 for dir in $dirs; do
-  AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
+  AT_CHECK_MAKE([], [absbuild/$dir])
 done
 
 # These will not pass with BSD make.
-AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
-AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
-AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
+AT_CHECK_MAKE([|| exit 77], [space])
+AT_CHECK_MAKE([], [build/space])
+AT_CHECK_MAKE([], [absbuild/space])
+
 
 AT_CLEANUP