automake
[Top][All Lists]
Advanced

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

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


From: Stefano Lattarini
Subject: [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: Wed, 6 Apr 2011 15:14:15 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

[adding automake-patches]
[IMHO further answers can drop automake and bug-gnulib]

Reference:
 <http://lists.gnu.org/archive/html/automake/2011-04/msg00011.html>

On Sunday 03 April 2011, Bruno Haible wrote:
> Hi Ralf, Stefano,
> 
> > I'll make amend by writing the new testcases, if you can wait some more
> > time (maybe a couple of days).
>
> Thanks. You can take this as input (I have copyright assignment on file with
> Automake):
>
> [BIG CUT]
>
Done in the attached patch.  I've put Bruno as the primary author in the
ChangeLog because he did most of the real work here.

The patch has been tested on Debian GNU/Linux with gcc 4.4 and the Sun C
compiler, GNU make (from 3.79 to 3.82), FreeBSD and NetBSD make ports,
and Heirloom tools, and on Solaris with native XPG4 and CCS make, dmake,
and GNU make 3.82.

OK for master?  I'll push in 72 hours if there is no objection.

Thanks,
  Stefano
From 0135ac16833adc391ac32b02250c6b80f68f5353 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/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                                   |   14 +++
 tests/Makefile.am                           |    8 ++
 tests/Makefile.in                           |    8 ++
 tests/remake-deleted-m4-file.test           |   73 ++++++++++++++
 tests/remake-gnulib-add-acsubst.test        |  138 +++++++++++++++++++++++++++
 tests/remake-gnulib-add-header.test         |  114 ++++++++++++++++++++++
 tests/remake-gnulib-remove-header.test      |  138 +++++++++++++++++++++++++++
 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 ++++++++++++++
 11 files changed, 818 insertions(+), 0 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..98cd00a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-04-05  Bruno Haible  <address@hidden>
+           Stefano Lattarini  <address@hidden>
+
+       coverage: add tests on remake rules in more complex situations
+       * 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/remake-deleted-m4-file.test 
b/tests/remake-deleted-m4-file.test
new file mode 100755
index 0000000..25176cc
--- /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
+
+$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
+
+$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..28b7120
--- /dev/null
+++ b/tests/remake-gnulib-add-acsubst.test
@@ -0,0 +1,138 @@
+#! /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
+
+if $MAKE --version | grep GNU; then
+  using_gmake=:
+else
+  using_gmake=false
+fi
+
+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..e85513a
--- /dev/null
+++ b/tests/remake-gnulib-add-header.test
@@ -0,0 +1,114 @@
+#! /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
+
+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
+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 speel 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..8dcbcc7
--- /dev/null
+++ b/tests/remake-gnulib-remove-header.test
@@ -0,0 +1,138 @@
+#! /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
+
+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
+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..6bfd47a
--- /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
+$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
+$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..bc5ce83
--- /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
+$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
+$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
+$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..7c062b0
--- /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
+$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
+$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..8792608
--- /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
+
+$MAKE Makefile
+$MAKE check
+
+$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
+
+$MAKE Makefile
+$MAKE check
+
+:
-- 
1.7.2.3


reply via email to

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