automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] {master} coverage: add tests on remake rules in more complex


From: Stefano Lattarini
Subject: Re: [PATCH] {master} coverage: add tests on remake rules in more complex situations (was: Re: not breaking "make" after m4 macros and source files changed)
Date: Fri, 8 Apr 2011 12:54:27 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Thursday 07 April 2011, Bruno Haible wrote:
> Hi Stefano,
> 
> > Done in the attached patch.
> 
> Great! I'm glad that you could use my input, although I mostly don't know 
> about
> the usual habits and idioms for automake unit tests.
> 
> Comments:
> 
> - In remake-renamed-m4-macro.test you use "$MAKE test" once and then
>   "$MAKE check" (twice). Is this intentional?
>
No, just remains from a previous version of the script.  Thanks for spotting it.

>   Isn't the 'check' target void?  "$MAKE test" would verify that in the
>   regenerated Makefile, $(the_answer) still has the same value.
>
Indeed.  It's fixed now.

> - In remake-gnulib-add-acsubst.test you avoid the "$MAKE Makefile" when using
>   GNU make:
>     $using_gmake || $MAKE Makefile
>   Would it be possible to use this idiom also in the other remake-*-m4-* 
> tests?
>
Sure, why not?  But than it's IMHO worth factorizing the 'using_gmake' idiom
out, in a subroutine defined in `tests/defs'.  That's what I've done (see the
attached squash-in).

> - In remake-gnulib-add-header.test: s/speel/sleep/
>
Oops, fixed.

> Otherwise, very nicely done! Thank you!!
>
Thank you for the review.

The squash-in and the updated patch are attached.  I'll push in 72 hours
if there is no objection.

Regards,
  Stefano
diff --git a/ChangeLog b/ChangeLog
index 98cd00a..3d0276d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,9 @@
-2011-04-05  Bruno Haible  <address@hidden>
+2011-04-08  Bruno Haible  <address@hidden>
            Stefano Lattarini  <address@hidden>
 
        coverage: add tests on remake rules in more complex situations
+       * tests/defs (using_gmake): New function.
+       (for tool in $required): Use it when $tool is 'GNUmake'.
        * tests/remake-moved-m4-file.test: New test.
        * tests/remake-deleted-m4-file.test: Likewise.
        * tests/remake-renamed-m4-file.test: Likewise.
diff --git a/tests/defs b/tests/defs
index f6237d3..2475709 100644
--- a/tests/defs
+++ b/tests/defs
@@ -146,6 +146,38 @@ AUTOMAKE_fails ()
   AUTOMAKE_run 1 ${1+"$@"}
 }
 
+# using_gmake
+# -----------
+# Return success if $MAKE is GNU make, return failure otherwise.
+# Caches the result for speed reasons.
+using_gmake ()
+{
+  case $am__using_gmake in
+    yes)
+      return 0
+      ;;
+    no)
+      return 1
+      ;;
+    '') 
+      # Use --version AND -v, because SGI Make doesn't fail on --version.
+      # Also grep for GNU because newer versions of FreeBSD make do
+      # not complain about `--version' (they seem to silently ignore it).
+      if $MAKE --version -v | grep GNU; then
+        am__using_gmake=yes
+        return 0
+      else
+        am__using_gmake=no
+        return 1
+      fi
+      ;;
+    *)
+      echo "invalid value for \$am__using_gmake: '$am__using_gmake'" >&2
+      Exit 99
+      ;;
+  esac
+}
+
 commented_sed_unindent_prog='
   /^$/b                    # Nothing to do for empty lines.
   x                        # Get x<indent> into pattern space.
@@ -217,11 +249,8 @@ do
       etags --version -o /dev/null || exit 77
       ;;
     GNUmake)
-      # Use --version AND -v, because SGI Make doesn't fail on --version.
-      # Also grep for GNU because newer versions of FreeBSD make do
-      # not complain about `--version' (they seem to silently ignore it).
-      echo "$me: running $MAKE --version -v | grep GNU"
-      ( $MAKE --version -v | grep GNU ) || exit 77
+      echo "$me: determine if $MAKE is GNU make"
+      using_gmake || exit 77
       ;;
     gcc)
       # When gcc is required, export `CC=gcc' so that ./configure
diff --git a/tests/remake-deleted-m4-file.test 
b/tests/remake-deleted-m4-file.test
index 25176cc..144da2f 100755
--- a/tests/remake-deleted-m4-file.test
+++ b/tests/remake-deleted-m4-file.test
@@ -58,7 +58,7 @@ sed -e "s|BAR_MACRO|$macro_value|" m4/foo.m4 > t
 mv -f t m4/foo.m4
 rm -f m4/bar.m4
 
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 
 $sleep
@@ -67,7 +67,7 @@ sed -e "s|FOO_MACRO|$macro_value|" configure.in > t
 mv -f t configure.in
 rm -f m4/foo.m4
 
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 
 :
diff --git a/tests/remake-gnulib-add-acsubst.test 
b/tests/remake-gnulib-add-acsubst.test
index 28b7120..2377d80 100755
--- a/tests/remake-gnulib-add-acsubst.test
+++ b/tests/remake-gnulib-add-acsubst.test
@@ -23,12 +23,6 @@
 
 . ./defs || Exit 1
 
-if $MAKE --version | grep GNU; then
-  using_gmake=:
-else
-  using_gmake=false
-fi
-
 cat >> configure.in <<'END'
 AC_PROG_CC
 MY_MACROS
@@ -102,7 +96,7 @@ cat >> Makefile.am <<'END'
 edit_h += -e 's|address@hidden@|@barvar@|g'
 END
 
-$using_gmake || $MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE
 
 : AC_SUBST @zapvar@ and add it to foo.h.
@@ -130,7 +124,7 @@ cat >> m4/bar.m4 <<'END'
 AC_DEFUN([ZAP_MACRO], [zapvar=163; AC_SUBST([zapvar])])
 END
 
-$using_gmake || $MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE
 
 $MAKE distcheck
diff --git a/tests/remake-gnulib-add-header.test 
b/tests/remake-gnulib-add-header.test
index e85513a..39d10ce 100755
--- a/tests/remake-gnulib-add-header.test
+++ b/tests/remake-gnulib-add-header.test
@@ -23,12 +23,6 @@
 
 . ./defs || Exit 1
 
-if $MAKE --version | grep GNU; then
-  using_gmake=:
-else
-  using_gmake=false
-fi
-
 cat >> configure.in <<'END'
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_CC
@@ -98,13 +92,13 @@ test ! -f stdio.h
 # Also try our build rules in a VPATH build.
 $MAKE distcheck
 
-# No need to speel here: "./configure" and "make distcheck" above
+# No need to sleep here: "./configure" and "make distcheck" above
 # have already slept enough.
 
 sed -e 's/^\( *override_stdio\)=.*$/\1=:/' macros.m4 > t
 mv -f t macros.m4
 
-$using_gmake || $MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE
 ls -l
 test -f stdio.h
diff --git a/tests/remake-gnulib-remove-header.test 
b/tests/remake-gnulib-remove-header.test
index 8dcbcc7..338a2da 100755
--- a/tests/remake-gnulib-remove-header.test
+++ b/tests/remake-gnulib-remove-header.test
@@ -24,12 +24,6 @@
 
 . ./defs || Exit 1
 
-if $MAKE --version | grep GNU; then
-  using_gmake=:
-else
-  using_gmake=false
-fi
-
 cat >> configure.in <<'END'
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_CC
@@ -113,7 +107,7 @@ for vpath in : false; do
   diff $srcdir/macros.m4 t && Exit 99 # sanity check
   mv -f t $srcdir/macros.m4
 
-  $using_gmake || $MAKE Makefile
+  using_gmake || $MAKE Makefile
   $MAKE
   ls -l
   test ! -f stdio.h
@@ -125,7 +119,7 @@ for vpath in : false; do
   diff $srcdir/macros.m4 t && Exit 99 # sanity check
   mv -f t $srcdir/macros.m4
 
-  $using_gmake || $MAKE Makefile
+  using_gmake || $MAKE Makefile
   $MAKE
   ls -l
   test -f stdio.h
diff --git a/tests/remake-moved-m4-file.test b/tests/remake-moved-m4-file.test
index 6bfd47a..04cf36e 100755
--- a/tests/remake-moved-m4-file.test
+++ b/tests/remake-moved-m4-file.test
@@ -52,7 +52,7 @@ $MAKE test
 
 # Move one file.
 mv d1/foo.m4 d2/foo.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
@@ -64,7 +64,7 @@ test ! -f $distdir/d2/macros.m4
 # Move both files at once.
 mv d1/macros.m4 d3/macros.m4
 mv d2/foo.m4 d3/foo.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
diff --git a/tests/remake-renamed-m4-file.test 
b/tests/remake-renamed-m4-file.test
index bc5ce83..ad01f6c 100755
--- a/tests/remake-renamed-m4-file.test
+++ b/tests/remake-renamed-m4-file.test
@@ -52,7 +52,7 @@ $MAKE test
 # Rename one file at the time.
 
 mv m4/foo.m4 m4/bar.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
@@ -60,7 +60,7 @@ test -f $distdir/m4/bar.m4
 test ! -f $distdir/m4/foo.m4
 
 mv m4/macros.m4 m4/defs.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
@@ -71,7 +71,7 @@ test ! -f $distdir/m4/macros.m4
 
 mv m4/bar.m4 m4/quux.m4
 mv m4/defs.m4 acinclude.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
diff --git a/tests/remake-renamed-m4-macro-and-file.test 
b/tests/remake-renamed-m4-macro-and-file.test
index 7c062b0..8fa784d 100755
--- a/tests/remake-renamed-m4-macro-and-file.test
+++ b/tests/remake-renamed-m4-macro-and-file.test
@@ -58,7 +58,7 @@ sed -e 's/FOO_MACRO/BAR_MACRO/' m4/foo.m4 > m4/bar.m4
 rm -f m4/foo.m4
 sed -e 's/FOO_MACRO/BAR_MACRO/' m4/macros.m4 > t
 mv -f t m4/macros.m4
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
@@ -76,7 +76,7 @@ sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' \
 rm -f m4/macros.m4 m4/bar.m4
 sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' configure.in > t
 mv -f t configure.in
-$MAKE Makefile
+using_gmake || $MAKE Makefile
 $MAKE test
 $MAKE distdir
 ls -l $distdir $distdir/*
diff --git a/tests/remake-renamed-m4-macro.test 
b/tests/remake-renamed-m4-macro.test
index 8792608..b34e42f 100755
--- a/tests/remake-renamed-m4-macro.test
+++ b/tests/remake-renamed-m4-macro.test
@@ -57,8 +57,8 @@ for x in macros foo; do
 done
 unset x
 
-$MAKE Makefile
-$MAKE check
+using_gmake || $MAKE Makefile
+$MAKE test
 
 $sleep
 
@@ -68,7 +68,7 @@ for f in m4/macros.m4 configure.in; do
 done
 unset f
 
-$MAKE Makefile
-$MAKE check
+using_gmake || $MAKE Makefile
+$MAKE test
 
 :
From f5f04ea3c84eb845f2bf2076ec7920be9963cc90 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 6 Apr 2011 14:45:40 +0200
Subject: [PATCH] coverage: add tests on remake rules in more complex situations

* tests/defs (using_gmake): New function.
(for tool in $required): Use it when $tool is 'GNUmake'.
* tests/remake-moved-m4-file.test: New test.
* tests/remake-deleted-m4-file.test: Likewise.
* tests/remake-renamed-m4-file.test: Likewise.
* tests/remake-renamed-m4-macro-and-file.test: Likewise.
* tests/remake-renamed-m4-macro.test: Likewise.
* tests/remake-add-acsubst-gnulib.test: Likewise.
* tests/remake-add-header-gnulib.test: Likewise.
* tests/remake-remove-header-gnulib.test: Likewise.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog                                   |   16 +++
 tests/Makefile.am                           |    8 ++
 tests/Makefile.in                           |    8 ++
 tests/defs                                  |   39 +++++++-
 tests/remake-deleted-m4-file.test           |   73 +++++++++++++++
 tests/remake-gnulib-add-acsubst.test        |  132 +++++++++++++++++++++++++++
 tests/remake-gnulib-add-header.test         |  108 ++++++++++++++++++++++
 tests/remake-gnulib-remove-header.test      |  132 +++++++++++++++++++++++++++
 tests/remake-moved-m4-file.test             |   78 ++++++++++++++++
 tests/remake-renamed-m4-file.test           |   85 +++++++++++++++++
 tests/remake-renamed-m4-macro-and-file.test |   88 ++++++++++++++++++
 tests/remake-renamed-m4-macro.test          |   74 +++++++++++++++
 12 files changed, 836 insertions(+), 5 deletions(-)
 create mode 100755 tests/remake-deleted-m4-file.test
 create mode 100755 tests/remake-gnulib-add-acsubst.test
 create mode 100755 tests/remake-gnulib-add-header.test
 create mode 100755 tests/remake-gnulib-remove-header.test
 create mode 100755 tests/remake-moved-m4-file.test
 create mode 100755 tests/remake-renamed-m4-file.test
 create mode 100755 tests/remake-renamed-m4-macro-and-file.test
 create mode 100755 tests/remake-renamed-m4-macro.test

diff --git a/ChangeLog b/ChangeLog
index d8750df..3d0276d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-04-08  Bruno Haible  <address@hidden>
+           Stefano Lattarini  <address@hidden>
+
+       coverage: add tests on remake rules in more complex situations
+       * tests/defs (using_gmake): New function.
+       (for tool in $required): Use it when $tool is 'GNUmake'.
+       * tests/remake-moved-m4-file.test: New test.
+       * tests/remake-deleted-m4-file.test: Likewise.
+       * tests/remake-renamed-m4-file.test: Likewise.
+       * tests/remake-renamed-m4-macro-and-file.test: Likewise.
+       * tests/remake-renamed-m4-macro.test: Likewise.
+       * tests/remake-add-acsubst-gnulib.test: Likewise.
+       * tests/remake-add-header-gnulib.test: Likewise.
+       * tests/remake-remove-header-gnulib.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-04-02  Stefano Lattarini  <address@hidden>
 
        tests: fix timestamp-related failures
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7f165ac..7419fee 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -787,6 +787,14 @@ remake10b.test \
 remake10c.test \
 remake11.test \
 remake12.test \
+remake-gnulib-add-acsubst.test \
+remake-gnulib-add-header.test \
+remake-gnulib-remove-header.test \
+remake-moved-m4-file.test \
+remake-deleted-m4-file.test \
+remake-renamed-m4-file.test \
+remake-renamed-m4-macro-and-file.test \
+remake-renamed-m4-macro.test \
 pr8365-remake-timing.test \
 regex.test \
 regex-obsolete.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index d1e3a73..bec2285 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1048,6 +1048,14 @@ remake10b.test \
 remake10c.test \
 remake11.test \
 remake12.test \
+remake-gnulib-add-acsubst.test \
+remake-gnulib-add-header.test \
+remake-gnulib-remove-header.test \
+remake-moved-m4-file.test \
+remake-deleted-m4-file.test \
+remake-renamed-m4-file.test \
+remake-renamed-m4-macro-and-file.test \
+remake-renamed-m4-macro.test \
 pr8365-remake-timing.test \
 regex.test \
 regex-obsolete.test \
diff --git a/tests/defs b/tests/defs
index f6237d3..2475709 100644
--- a/tests/defs
+++ b/tests/defs
@@ -146,6 +146,38 @@ AUTOMAKE_fails ()
   AUTOMAKE_run 1 ${1+"$@"}
 }
 
+# using_gmake
+# -----------
+# Return success if $MAKE is GNU make, return failure otherwise.
+# Caches the result for speed reasons.
+using_gmake ()
+{
+  case $am__using_gmake in
+    yes)
+      return 0
+      ;;
+    no)
+      return 1
+      ;;
+    '') 
+      # Use --version AND -v, because SGI Make doesn't fail on --version.
+      # Also grep for GNU because newer versions of FreeBSD make do
+      # not complain about `--version' (they seem to silently ignore it).
+      if $MAKE --version -v | grep GNU; then
+        am__using_gmake=yes
+        return 0
+      else
+        am__using_gmake=no
+        return 1
+      fi
+      ;;
+    *)
+      echo "invalid value for \$am__using_gmake: '$am__using_gmake'" >&2
+      Exit 99
+      ;;
+  esac
+}
+
 commented_sed_unindent_prog='
   /^$/b                    # Nothing to do for empty lines.
   x                        # Get x<indent> into pattern space.
@@ -217,11 +249,8 @@ do
       etags --version -o /dev/null || exit 77
       ;;
     GNUmake)
-      # Use --version AND -v, because SGI Make doesn't fail on --version.
-      # Also grep for GNU because newer versions of FreeBSD make do
-      # not complain about `--version' (they seem to silently ignore it).
-      echo "$me: running $MAKE --version -v | grep GNU"
-      ( $MAKE --version -v | grep GNU ) || exit 77
+      echo "$me: determine if $MAKE is GNU make"
+      using_gmake || exit 77
       ;;
     gcc)
       # When gcc is required, export `CC=gcc' so that ./configure
diff --git a/tests/remake-deleted-m4-file.test 
b/tests/remake-deleted-m4-file.test
new file mode 100755
index 0000000..144da2f
--- /dev/null
+++ b/tests/remake-deleted-m4-file.test
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when an m4 file gets removed and the macros it
+# defined gets inlined into the caller.  Try with both an indirect
+# call and a direct one.  This can be seen as testing the "deleted
+# header file" issue w.r.t. aclocal.m4 dependencies.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+FOO_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+       test '$(the_answer)' = 42
+END
+
+macro_value='the_answer=42; AC_SUBST([the_answer])'
+
+mkdir m4
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [BAR_MACRO])
+END
+
+cat > m4/bar.m4 <<END
+AC_DEFUN([BAR_MACRO], [$macro_value])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+$sleep
+
+sed -e "s|BAR_MACRO|$macro_value|" m4/foo.m4 > t
+mv -f t m4/foo.m4
+rm -f m4/bar.m4
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+$sleep
+
+sed -e "s|FOO_MACRO|$macro_value|" configure.in > t
+mv -f t configure.in
+rm -f m4/foo.m4
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+:
diff --git a/tests/remake-gnulib-add-acsubst.test 
b/tests/remake-gnulib-add-acsubst.test
new file mode 100755
index 0000000..2377d80
--- /dev/null
+++ b/tests/remake-gnulib-add-acsubst.test
@@ -0,0 +1,132 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when a new AC_SUBST'd variable is added, and C header
+# files are involved.
+# This test overlaps with others, and is not strictly necessary per se,
+# but it exercises a real use case (from gnulib, see:
+#  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info), so keep it anyway.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = foo.h
+edit_h = sed -e 's|address@hidden@|@foovar@|g'
+foo.h: foo.in.h
+       $(edit_h) < $(srcdir)/foo.in.h > address@hidden
+       cat address@hidden;: for debugging
+       mv -f address@hidden $@
+EXTRA_DIST = foo.in.h
+MOSTLYCLEANFILES = foo.h foo.h-t
+END
+
+mkdir m4
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+     FOO_MACRO
+dnl: ZAP_MACRO
+])
+END
+
+cat > m4/bar.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [
+     foovar=42; AC_SUBST([foovar])
+dnl: barvar=47; AC_SUBST([barvar])
+])
+END
+
+cat > foo.in.h <<'END'
+#define foo @foovar@
+END
+
+cat > foo.c <<'END'
+#include "foo.h"
+int main (void) { return 0; }
+typedef int checkfoo[1 - 2 * (foo != 42)];
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+: AC_SUBST @barvar@ and add it to foo.h.
+
+$sleep
+
+sed -e 's/^dnl:/   /' m4/bar.m4 > t
+mv -f t m4/bar.m4
+cat m4/bar.m4
+
+cat >> foo.in.h <<'END'
+#define bar @barvar@
+END
+
+cat >> foo.c <<'END'
+typedef int checkbar[1 - 2 * (bar != 47)];
+END
+
+cat >> Makefile.am <<'END'
+edit_h += -e 's|address@hidden@|@barvar@|g'
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+
+: AC_SUBST @zapvar@ and add it to foo.h.
+# Do it in a slightly different way from how it was done for @address@hidden
+
+$sleep
+
+cat >> Makefile.am <<'END'
+edit_h += -e 's|address@hidden@|$(zapvar)|g'
+END
+
+cat >> foo.c <<'END'
+typedef int checkzap[1 - 2 * (zap != 163)];
+END
+
+sed -e 's/^dnl://' m4/foo.m4 > t
+mv -f t m4/foo.m4
+cat m4/foo.m4
+
+cat >> foo.in.h <<'END'
+#define zap @zapvar@
+END
+
+cat >> m4/bar.m4 <<'END'
+AC_DEFUN([ZAP_MACRO], [zapvar=163; AC_SUBST([zapvar])])
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+
+$MAKE distcheck
+
+:
diff --git a/tests/remake-gnulib-add-header.test 
b/tests/remake-gnulib-add-header.test
new file mode 100755
index 0000000..39d10ce
--- /dev/null
+++ b/tests/remake-gnulib-add-header.test
@@ -0,0 +1,108 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when a new C header "guarded" by AC_SUBST'd
+# variables is added.
+# This test overlaps with others, and is not strictly necessary per se,
+# but it exercises a real use case (from gnulib, see:
+#  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info), so please keep it anyway.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I .
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = $(STDIO_H)
+stdio.h: stdio.in.h
+       cp $(srcdir)/stdio.in.h $@
+MOSTLYCLEANFILES = stdio.h
+EXTRA_DIST = stdio.in.h
+check-local:
+       ls -l . $(srcdir)
+       if test -n '$(STDIO_H)'; then \
+           test -f stdio.h || exit 1; \
+       else \
+           test ! -f stdio.h || exit 1; \
+       fi
+END
+
+cat > macros.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+  override_stdio=false
+  if $override_stdio; then
+    STDIO_H=stdio.h
+    use_dummies=1
+  else
+    STDIO_H=
+    use_dummies=0
+  fi
+  AC_SUBST([STDIO_H])
+  AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
+    [Whether to use dummy types.])
+])
+END
+
+cat > stdio.in.h <<'END'
+typedef struct dummyfile { void *p; } DUMMYFILE;
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+#if USE_DUMMIES
+DUMMYFILE *f;
+#else
+FILE *f;
+#endif
+int main () { return 0; }
+END
+
+$ACLOCAL -I .
+$AUTOHEADER
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+$MAKE
+ls -l
+test ! -f stdio.h
+# Also try our build rules in a VPATH build.
+$MAKE distcheck
+
+# No need to sleep here: "./configure" and "make distcheck" above
+# have already slept enough.
+
+sed -e 's/^\( *override_stdio\)=.*$/\1=:/' macros.m4 > t
+mv -f t macros.m4
+
+using_gmake || $MAKE Makefile
+$MAKE
+ls -l
+test -f stdio.h
+# Also try our build rules in a VPATH build.
+$MAKE distcheck
+
+:
diff --git a/tests/remake-gnulib-remove-header.test 
b/tests/remake-gnulib-remove-header.test
new file mode 100755
index 0000000..338a2da
--- /dev/null
+++ b/tests/remake-gnulib-remove-header.test
@@ -0,0 +1,132 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when a C header "guarded" by AC_SUBST'd variables
+# is not needed anymore, or when it's needed back.
+# This test requires some user-level machinery, overlaps with other tests,
+# and is not strictly necessary per se, but it exercises a real, important
+# use case (from gnulib, see:
+#  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info), so please keep it anyway.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I .
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = $(STDIO_H)
+if REPLACE_STDIO_H
+stdio.h: stdio.in.h $(top_builddir)/config.status
+       cp $(srcdir)/stdio.in.h $@
+else
+stdio.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES = stdio.h
+END
+
+cat > macros.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+  override_stdio=:
+  if $override_stdio; then
+    STDIO_H=stdio.h
+    use_dummies=1
+  else
+    STDIO_H=
+    use_dummies=0
+  fi
+  AC_SUBST([STDIO_H])
+  AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
+    [Whether to use dummy types.])
+  AM_CONDITIONAL([REPLACE_STDIO_H], [test -n "$STDIO_H"])
+])
+END
+
+cat > stdio.in.h <<'END'
+typedef struct dummyfile { void *p; } DUMMYFILE;
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+#if USE_DUMMIES
+DUMMYFILE *f;
+#else
+FILE *f;
+#endif
+int main () { return 0; }
+END
+
+$ACLOCAL -I .
+$AUTOHEADER
+$AUTOMAKE
+$AUTOCONF
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  # Do not reject slow dependency extractors: we need dependency tracking.
+  $srcdir/configure --enable-dependency-tracking
+
+  $MAKE
+  ls -l
+  test -f stdio.h
+
+  # Simulate that we don't need our custom stdio.h anymore.
+
+  $sleep
+  sed -e 's/^\( *override_stdio\)=.*$/\1=false/' $srcdir/macros.m4 > t
+  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  mv -f t $srcdir/macros.m4
+
+  using_gmake || $MAKE Makefile
+  $MAKE
+  ls -l
+  test ! -f stdio.h
+
+  # And now simulate that we want our custom stdio.h back.
+
+  $sleep
+  sed -e 's/^\( *override_stdio\)=.*$/\1=:/' $srcdir/macros.m4 > t
+  diff $srcdir/macros.m4 t && Exit 99 # sanity check
+  mv -f t $srcdir/macros.m4
+
+  using_gmake || $MAKE Makefile
+  $MAKE
+  ls -l
+  test -f stdio.h
+
+  $MAKE distclean
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/remake-moved-m4-file.test b/tests/remake-moved-m4-file.test
new file mode 100755
index 0000000..04cf36e
--- /dev/null
+++ b/tests/remake-moved-m4-file.test
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when an m4 files gets moved among different "include
+# dirs" (i.e. those passed to aclocal with `-I' option).
+
+. ./defs || Exit 1
+
+distdir=$me-1.0
+
+cat >> configure.in <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I d1 -I d2 -I d3
+.PHONY: test
+test:
+       test '$(the_answer)' = 42
+END
+
+mkdir d1 d2 d3
+
+cat > d1/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO])
+END
+
+cat > d1/foo.m4 <<'END'
+AC_DEFUN([FOO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I d1
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Move one file.
+mv d1/foo.m4 d2/foo.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/d2/foo.m4
+test ! -f $distdir/d1/foo.m4
+test -f $distdir/d1/macros.m4
+test ! -f $distdir/d2/macros.m4
+
+# Move both files at once.
+mv d1/macros.m4 d3/macros.m4
+mv d2/foo.m4 d3/foo.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/d3/foo.m4
+test -f $distdir/d3/macros.m4
+test ! -f $distdir/d1/foo.m4
+test ! -f $distdir/d2/foo.m4
+test ! -f $distdir/d1/macros.m4
+test ! -f $distdir/d2/macros.m4
+
+:
diff --git a/tests/remake-renamed-m4-file.test 
b/tests/remake-renamed-m4-file.test
new file mode 100755
index 0000000..ad01f6c
--- /dev/null
+++ b/tests/remake-renamed-m4-file.test
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when m4 files gets renamed.
+
+. ./defs || Exit 1
+
+distdir=$me-1.0
+
+cat >> configure.in <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+       test '$(the_answer)' = 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Rename one file at the time.
+
+mv m4/foo.m4 m4/bar.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/foo.m4
+
+mv m4/macros.m4 m4/defs.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/defs.m4
+test ! -f $distdir/m4/macros.m4
+
+# Rename both files at once.
+
+mv m4/bar.m4 m4/quux.m4
+mv m4/defs.m4 acinclude.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/quux.m4
+test -f $distdir/acinclude.m4
+test ! -f $distdir/m4/foo.m4
+test ! -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/macros.m4
+test ! -f $distdir/m4/defs.m4
+
+:
diff --git a/tests/remake-renamed-m4-macro-and-file.test 
b/tests/remake-renamed-m4-macro-and-file.test
new file mode 100755
index 0000000..8fa784d
--- /dev/null
+++ b/tests/remake-renamed-m4-macro-and-file.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when an m4 file gets renamed and *simultaneously*
+# an m4 macro in it gets renamed.  Kudos to Bruno Haible for thinking
+# about this situation.
+
+. ./defs || Exit 1
+
+distdir=$me-1.0
+
+cat >> configure.in <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+       test '$(the_answer)' = 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO_MACRO])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Rename only one file and one macro.
+
+$sleep
+sed -e 's/FOO_MACRO/BAR_MACRO/' m4/foo.m4 > m4/bar.m4
+rm -f m4/foo.m4
+sed -e 's/FOO_MACRO/BAR_MACRO/' m4/macros.m4 > t
+mv -f t m4/macros.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/bar.m4
+test -f $distdir/m4/macros.m4
+test ! -f $distdir/m4/foo.m4
+
+# Rename both at once.
+
+$sleep
+sed -e 's/BAR_MACRO/QUUX_MACRO/' \
+  m4/bar.m4 > m4/quux.m4
+sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' \
+  m4/macros.m4 > m4/defs.m4
+rm -f m4/macros.m4 m4/bar.m4
+sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' configure.in > t
+mv -f t configure.in
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/quux.m4
+test -f $distdir/m4/defs.m4
+test ! -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/macros.m4
+
+:
diff --git a/tests/remake-renamed-m4-macro.test 
b/tests/remake-renamed-m4-macro.test
new file mode 100755
index 0000000..b34e42f
--- /dev/null
+++ b/tests/remake-renamed-m4-macro.test
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test remake rules when the name of an m4 macro change.  Try both with
+# and without indirection.
+
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+       test '$(the_answer)' = 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO_1])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_1], [the_answer=42
+                   AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+$sleep
+
+for x in macros foo; do
+  sed -e 's/FOO_1/FOO_2/' m4/$x.m4 > t
+  mv -f t m4/$x.m4
+done
+unset x
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+$sleep
+
+for f in m4/macros.m4 configure.in; do
+  sed -e 's/MY_MACRO/YOUR_MACRO/' $f > t
+  mv -f t $f
+done
+unset f
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+:
-- 
1.7.2.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]