[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Modernize and improve test scripts `subdir*.test'.
From: |
Stefano Lattarini |
Subject: |
Re: [PATCH] Modernize and improve test scripts `subdir*.test'. |
Date: |
Wed, 21 Jul 2010 23:28:17 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
At Wednesday 21 July 2010, Ralf Wildenhues wrote:
> Hi Stefano,
>
> This is ok for maint with nits below addressed.
>
> > diff --git a/tests/subdir5.test b/tests/subdir5.test
> > index 2f0113b..0709440 100755
> > --- a/tests/subdir5.test
> > +++ b/tests/subdir5.test
> >
> > @@ -27,14 +27,15 @@ required='GNUmake gcc'
> >
> > set -e
> >
> > -cat > configure.in << 'END'
> > -AC_INIT(maude, 1.0)
> > -AM_INIT_AUTOMAKE
> > +cat >> configure.in << 'END'
> > +AC_PROG_CC
> >
> > AM_PROG_CC_C_O
> >
> > -AC_CONFIG_FILES(Makefile)
> > +m4_include([confiles.m4])
>
> I don't understand why this change doesn't change the nature of the
> test.
Indeed it does :-( I was a bit mislead by a comments in subdir8.test,
which seemed to imply that subdir8.test and subdir5.test were more
similar than they actually are.
> I mean, the first step users typically do when adding a new
> subdir is editing configure.ac, not editing a file that is included
> by configure.ac. I think the test really is meant to simulate just
> that, and if it is, it should be kept that way.
True enough.
> Also because when
> the m4_include is not present in the first version of the file,
> there is no dependency on confiles.m4 which makes a difference for
> the rerun and this different code path should be kept.
Correct again.
>
> Am I missing something?
>
No, it was me who was missing something. And the tests, too (they
were missing comments :-). What about these (squashed in the amended
patch)?
[subdir5.test]
# First we add a new directory by modifying configure.in directly.
... [LOT OF CODE]
# Then we add a new directory by modifying a file included (through
# `m4_include') by configure.in.
[subdir8.test]
# The first step users typically do when adding a new subdir is
# editing configure.in. That is already tested by subdir5.test,
# though, so here we try to just edit a file that is included by
# configure.in, without touching configure.in itself.
> > -: > maude/foo.h
> > -
> >
> > echo 'SUBDIRS = maude' >> Makefile.am
> >
> > +: > maude/foo.h
> > +
>
> Is there a reason for this reordering?
No, it seeped in inadvertently. Removed.
> > # We want a simple rebuild to create maude2/Makefile and update
> > # all other Makefiles automatically.
> > $MAKE
> >
> > -grep GREPME Makefile
> > -grep GREPME maude/Makefile
> > -grep GREPME maude2/Makefile
> > +$FGREP GREPME Makefile
> > +$FGREP GREPME maude/Makefile
> > +$FGREP GREPME maude2/Makefile
>
> This should not be necessary either.
And it's not -- I just prefer to use fgrep over grep when there is no
regexp involved. Thinking about it, it would be even better to use
grep with a stricter regexp instead, as in:
grep '^GREPME =' Makefile
This is what I've done in the amended patch (here and in subdir8.test
too).
> > --- a/tests/subdir6.test
> > +++ b/tests/subdir6.test
> > @@ -38,4 +38,5 @@ $MAKE clean
> >
> > test -f sub/stamp-h1
> > $MAKE distclean
> > test -f sub/stamp-h1 && Exit 1
> > +
> > :
>
> tsk. ;-)
A bit too much obsessive-compulsive-ish? :-)
>
> [ subdir8.test ]
>
> > @@ -81,8 +86,8 @@ echo 'SUBDIRS = maude' >> sub/Makefile.am
> >
> > mkdir maude
> >
> > : > maude/Makefile.am
> >
> > -# Update confile.m4 *after* updating sub/Makefile.am.
> > -# (subdir5.test do it in the other way: it updates configure.in
> > +# Update confiles.m4 *after* updating sub/Makefile.am.
> > +# (subdir5.test do it in the other way: it updates confiles.m4
> > # before Makefile.am)
>
> This is not needed with above comment addressed.
Right.
Attached are the amended patch (against maint) and the temporary patch
I squashed in the old one (which FYI was against master).
OK to apply?
Regards,
Stefano
From 842b14a6b7f8f71bcc4bf78891e0f87c090f4d3b Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Sat, 19 Jun 2010 14:55:10 +0200
Subject: [PATCH] Modernize and improve test scripts `subdir*.test'.
* tests/subdir.test: Enable `errexit' shell flag, and related
changes. Use the `configure.in' stub created by `./defs',
rather than writing one from scratch.
* tests/subdir2.test: Likewise.
* tests/subdir4.test: Likewise.
* tests/subdir3.test: Enable `errexit' shell flag, and related
changes. Do not create useless dummy source files.
* tests/subdir5.test: Make grepping of Makefile.in (in topdir
and in subdirs) stricter. Some minor changes to keep it more
in sync with the related test `subdir8.test'.
* tests/subdir8.test: Likewise (but with the related test being
`subdir5.test' here).
* tests/subdir6.test: Cosmetic change in spacing.
* tests/subdir9.test: Define and use new variable `$distdir'. Add
trailing `:' command.
* tests/subdir10.test: Cosmetic consistency-related change.
* tests/subdirbuiltsources.test: Cosmetic changes in spacings.
(configure.in): Use stub created by `./defs', rather than writing
it from scratch. Do not use obsoleted and/or deprecated forms of
autoconf/automake macros.
---
ChangeLog | 24 +++++++++++++++++++
tests/subdir.test | 16 ++++++++-----
tests/subdir10.test | 4 +-
tests/subdir2.test | 16 ++++++++-----
tests/subdir3.test | 15 +++++------
tests/subdir4.test | 17 +++++++------
tests/subdir5.test | 51 ++++++++++++++++++++++++-----------------
tests/subdir6.test | 3 +-
tests/subdir7.test | 10 +++++---
tests/subdir8.test | 37 ++++++++++++++++++++---------
tests/subdir9.test | 10 +++++--
tests/subdirbuiltsources.test | 13 ++++------
12 files changed, 137 insertions(+), 79 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 251ff2e..2306ff1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2010-07-21 Stefano Lattarini <address@hidden>
+
+ Modernize and improve test scripts `subdir*.test'.
+ * tests/subdir.test: Enable `errexit' shell flag, and related
+ changes. Use the `configure.in' stub created by `./defs',
+ rather than writing one from scratch.
+ * tests/subdir2.test: Likewise.
+ * tests/subdir4.test: Likewise.
+ * tests/subdir3.test: Enable `errexit' shell flag, and related
+ changes. Do not create useless dummy source files.
+ * tests/subdir5.test: Make grepping of Makefile.in (in topdir
+ and in subdirs) stricter. Some minor changes to keep it more
+ in sync with the related test `subdir8.test'.
+ * tests/subdir8.test: Likewise (but with the related test being
+ `subdir5.test' here).
+ * tests/subdir6.test: Cosmetic change in spacing.
+ * tests/subdir9.test: Define and use new variable `$distdir'. Add
+ trailing `:' command.
+ * tests/subdir10.test: Cosmetic consistency-related change.
+ * tests/subdirbuiltsources.test: Cosmetic changes in spacings.
+ (configure.in): Use stub created by `./defs', rather than writing
+ it from scratch. Do not use obsoleted and/or deprecated forms of
+ autoconf/automake macros.
+
2010-07-18 Stefano Lattarini <address@hidden>
Improve and extend test cond5.test.
diff --git a/tests/subdir.test b/tests/subdir.test
index 85db059..edad4ca 100755
--- a/tests/subdir.test
+++ b/tests/subdir.test
@@ -1,5 +1,6 @@
#! /bin/sh
-# Copyright (C) 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2010 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
@@ -19,12 +20,13 @@
. ./defs || Exit 1
+set -e
+
mkdir zot
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile zot/Makefile)
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([zot/Makefile])
+AC_OUTPUT
END
cat > Makefile.am << 'END'
@@ -35,5 +37,7 @@ cat > zot/Makefile.am << 'END'
pkgdata_DATA =
END
-$ACLOCAL || Exit 1
+$ACLOCAL
$AUTOMAKE
+
+:
diff --git a/tests/subdir10.test b/tests/subdir10.test
index c71216b..eabd1a9 100755
--- a/tests/subdir10.test
+++ b/tests/subdir10.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2009 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010 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
@@ -36,4 +36,4 @@ $AUTOMAKE
./configure
env fail=1 $MAKE all clean
-Exit 0
+:
diff --git a/tests/subdir2.test b/tests/subdir2.test
index aa83436..9412054 100755
--- a/tests/subdir2.test
+++ b/tests/subdir2.test
@@ -1,5 +1,6 @@
#! /bin/sh
-# Copyright (C) 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2010 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
@@ -18,13 +19,14 @@
. ./defs || Exit 1
+set -e
+
mkdir one
mkdir one/two
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile one/Makefile one/two/Makefile)
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([one/Makefile one/two/Makefile])
+AC_OUTPUT
END
# Files required because we are using `--gnu'.
@@ -47,5 +49,7 @@ cat > one/two/Makefile.am << 'END'
pkgdata_DATA =
END
-$ACLOCAL || Exit 1
+$ACLOCAL
$AUTOMAKE --gnu
+
+:
diff --git a/tests/subdir3.test b/tests/subdir3.test
index aa02be0..3da2cc8 100755
--- a/tests/subdir3.test
+++ b/tests/subdir3.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2010 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
@@ -18,6 +18,8 @@
. ./defs || Exit 1
+set -e
+
cat > Makefile.am << 'END'
bin_PROGRAMS = zardoz widdershins
zardoz_SOURCES = y.c x/z.c
@@ -28,12 +30,9 @@ cat >> configure.in << 'END'
AC_PROG_CC
END
-mkdir x
-
-: > y.c
-: > x/z.c
-
-$ACLOCAL || Exit 1
-$AUTOMAKE || Exit 1
+$ACLOCAL
+$AUTOMAKE
grep '^z\.o: x/z\.c$' Makefile.in
+
+:
diff --git a/tests/subdir4.test b/tests/subdir4.test
index 2f85213..7ea10f8 100755
--- a/tests/subdir4.test
+++ b/tests/subdir4.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2010 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
@@ -19,14 +19,15 @@
. ./defs || Exit 1
+set -e
+
mkdir lib src
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+cat >> configure.in << 'END'
AC_PROG_RANLIB
AC_PROG_CC
-AC_OUTPUT(Makefile lib/Makefile src/Makefile)
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AC_OUTPUT
END
# Files required because we are using `--gnu'.
@@ -55,8 +56,8 @@ cat > src/Makefile.am << 'END'
pkgdata_DATA =
END
-$ACLOCAL || Exit 1
-$AUTOMAKE --gnu || Exit 1
+$ACLOCAL
+$AUTOMAKE --gnu
# Make sure that depcomp is *not* included in the definition
# of DIST_COMMON in lib/Makefile.in. If you change this test
@@ -65,4 +66,4 @@ $AUTOMAKE --gnu || Exit 1
# continued line.
grep '^DIST_COMMON.*depcomp' lib/Makefile.in && Exit 1
-Exit 0
+:
diff --git a/tests/subdir5.test b/tests/subdir5.test
index 2f0113b..ce60e9b 100755
--- a/tests/subdir5.test
+++ b/tests/subdir5.test
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2003, 2004, 2009 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2009, 2010 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
@@ -22,16 +22,15 @@
# This test assumes that the `make' utility is able to start
# over and reload Makefiles which have been remade (a non-POSIX feature).
+# See also the related test subdir8.test.
required='GNUmake gcc'
. ./defs || Exit 1
set -e
-cat > configure.in << 'END'
-AC_INIT(maude, 1.0)
-AM_INIT_AUTOMAKE
+cat >> configure.in << 'END'
+AC_PROG_CC
AM_PROG_CC_C_O
-AC_CONFIG_FILES(Makefile)
AC_OUTPUT
END
@@ -55,26 +54,30 @@ $AUTOMAKE --include-deps --copy --add-missing
./configure
$MAKE
+# Now add new directories.
+#
# We shouldn't need to $sleep here: configure ensures that files
# generated by it are newer than configure. Thus, even if
# Makefile.in is newer than configure but the updated Makefile.am
# below has the same timestamp as Makefile.in, the latter should
# be rebuilt due to its dependency on configure.in.
-# Now add a new directory.
-cat > configure.in << 'END'
-AC_INIT(maude, 1.0)
-AM_INIT_AUTOMAKE
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES(Makefile maude/Makefile)
-m4_include([confile.m4])
-AC_OUTPUT
-END
+# First we add a new directory by, modifying configure.in directly.
+# We update configure.in *before* updating sub/Makefile.am; subdir8.test
+# do it in the other way: it updates confiles.m4 (which is m4_included by
+# configure.in there) after Makefile.am.
+
+sed <configure.in >configure.tmp -e '/^AC_OUTPUT$/i\
+AC_CONFIG_FILES([maude/Makefile])\
+m4_include([confile.m4])'
+mv -f configure.tmp configure.in
+
+cat configure.in # might be useful for debugging
: > confile.m4
mkdir maude
+
cat > maude/Makefile.am << 'END'
include_HEADERS = foo.h
END
@@ -87,15 +90,21 @@ echo 'SUBDIRS = maude' >> Makefile.am
$MAKE
test -f maude/Makefile
-# Add yet another directory
+# Then we add a new directory by modifying a file included (through
+# `m4_include') by configure.in.
mkdir maude2
-echo 'AC_CONFIG_FILES([maude2/Makefile])AC_SUBST([GREPME])' > confile.m4
+cat >> confile.m4 << 'END'
+AC_CONFIG_FILES([maude2/Makefile])
+AC_SUBST([GREPME])
+END
: > maude2/Makefile.am
echo 'SUBDIRS += maude2' >> Makefile.am
# We want a simple rebuild to create maude2/Makefile and update
# all other Makefiles automatically.
$MAKE
-grep GREPME Makefile
-grep GREPME maude/Makefile
-grep GREPME maude2/Makefile
+grep '^GREPME =' Makefile
+grep '^GREPME =' maude/Makefile
+grep '^GREPME =' maude2/Makefile
+
+:
diff --git a/tests/subdir6.test b/tests/subdir6.test
index 81221ff..f3a2107 100755
--- a/tests/subdir6.test
+++ b/tests/subdir6.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2010 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
@@ -38,4 +38,5 @@ $MAKE clean
test -f sub/stamp-h1
$MAKE distclean
test -f sub/stamp-h1 && Exit 1
+
:
diff --git a/tests/subdir7.test b/tests/subdir7.test
index e72f489..b50b250 100755
--- a/tests/subdir7.test
+++ b/tests/subdir7.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2010 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
@@ -23,7 +23,7 @@ set -e
mkdir obj
cat >>configure.in << 'END'
-AC_CONFIG_FILES(obj/Makefile)
+AC_CONFIG_FILES([obj/Makefile])
AC_OUTPUT
END
@@ -35,11 +35,13 @@ $ACLOCAL
AUTOMAKE_fails
grep 'Makefile.am:1:.*obj.*BSD' stderr
-cat >Makefile.am <<'EOF'
+cat >Makefile.am <<'END'
SUBDIRS = @STH@
FOO = obj
DIST_SUBDIRS = $(FOO)
-EOF
+END
AUTOMAKE_fails
grep 'Makefile.am:2:.*obj.*BSD' stderr
+
+:
diff --git a/tests/subdir8.test b/tests/subdir8.test
index bc3043e..093fac8 100755
--- a/tests/subdir8.test
+++ b/tests/subdir8.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003, 2004, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2009, 2010 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
@@ -21,13 +21,12 @@
# This test assumes that the `make' utility is able to start
# over and reload Makefiles which have been remade (a non-POSIX feature).
+# See also the related test subdir5.test.
required='GNUmake gcc'
. ./defs || Exit 1
set -e
-echo 'AC_CONFIG_FILES([sub/Makefile])' >confiles.m4
-
cat >> configure.in << 'END'
AC_PROG_CC
AM_PROG_CC_C_O
@@ -36,6 +35,8 @@ MORE_DEFS
AC_OUTPUT
END
+echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
+
cat > Makefile.am << 'END'
SUBDIRS = sub
ACLOCAL_AMFLAGS = -I m4
@@ -66,8 +67,18 @@ $AUTOMAKE --copy --add-missing
./configure
$MAKE
-# Now add a new directory.
-# See subdir5.test for why we shouldn't need to $sleep here.
+# Now add new directories.
+#
+# We shouldn't need to $sleep here: configure ensures that files
+# generated by it are newer than configure. Thus, even if
+# Makefile.in is newer than configure but the updated Makefile.am
+# below has the same timestamp as Makefile.in, the latter should
+# be rebuilt due to its dependency on configure.in.
+
+# The first step users typically do when adding a new subdir is
+# editing configure.in. That is already tested by subdir5.test,
+# though, so here we try to just edit a file that is included by
+# configure.in, without touching configure.in itself.
mkdir sub/maude
cat > sub/maude/Makefile.am << 'END'
@@ -81,9 +92,8 @@ echo 'SUBDIRS = maude' >> sub/Makefile.am
mkdir maude
: > maude/Makefile.am
-# Update confile.m4 *after* updating sub/Makefile.am.
-# (subdir5.test do it in the other way: it updates configure.in
-# before Makefile.am)
+# Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
+# it in the other way: it updates configure.in before Makefile.am.
echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
# We want a simple rebuild from sub/ to create sub/maude/Makefile
@@ -98,7 +108,10 @@ test -f sub/maude/Makefile
# the top-level directory.
echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
$MAKE
-grep GREPME Makefile
-grep GREPME maude/Makefile
-grep GREPME sub/Makefile
-grep GREPME sub/maude/Makefile
+
+grep '^GREPME =' Makefile
+grep '^GREPME =' maude/Makefile
+grep '^GREPME =' sub/Makefile
+grep '^GREPME =' sub/maude/Makefile
+
+:
diff --git a/tests/subdir9.test b/tests/subdir9.test
index 4346326..c73ca18 100755
--- a/tests/subdir9.test
+++ b/tests/subdir9.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2010 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
@@ -43,13 +43,17 @@ cat >src/subdir2/Makefile.am <<'EOF'
EXTRA_DIST = foo
EOF
+distdir=$me-1.0
+
$ACLOCAL
$AUTOCONF
$AUTOMAKE --copy --add-missing
./configure
$MAKE distdir
-test -f subdir9-1.0/src/subdir/foo
-test -f subdir9-1.0/src/subdir2/foo
+test -f $distdir/src/subdir/foo
+test -f $distdir/src/subdir2/foo
$MAKE clean
$MAKE distclean
test ! -f src/subdir2/Makefile
+
+:
diff --git a/tests/subdirbuiltsources.test b/tests/subdirbuiltsources.test
index 8fe506a..a84f28e 100755
--- a/tests/subdirbuiltsources.test
+++ b/tests/subdirbuiltsources.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2010 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
@@ -24,12 +24,11 @@ set -e
mkdir lib
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([lib/Makefile])
AC_PROG_RANLIB
AC_PROG_CC
-AC_OUTPUT(Makefile lib/Makefile)
+AC_OUTPUT
END
# Files required because we are using `--gnu'.
@@ -60,9 +59,7 @@ END
$ACLOCAL
-
$AUTOCONF
-
$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu
./configure
@@ -71,4 +68,4 @@ $AUTOMAKE --include-deps --copy --force-missing --add-missing
--gnu
# $MAKE -C lib foo.h
$MAKE
-Exit 0
+:
--
1.7.1
From 60ec093665da62a250862ebb13b69d661d690ffd Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 21 Jul 2010 23:07:46 +0200
Subject: [PATCH 2/2] to be squashed in
---
ChangeLog | 12 ++++++------
tests/subdir5.test | 42 ++++++++++++++++++++++++------------------
tests/subdir8.test | 22 ++++++++++++++--------
3 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2a5b908..82f4b3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-2010-06-19 Stefano Lattarini <address@hidden>
+2010-07-21 Stefano Lattarini <address@hidden>
Modernize and improve test scripts `subdir*.test'.
* tests/subdir.test: Enable `errexit' shell flag, and related
@@ -8,11 +8,11 @@
* tests/subdir4.test: Likewise.
* tests/subdir3.test: Enable `errexit' shell flag, and related
changes. Do not create useless dummy source files.
- * tests/subdir8.test: Prefer fgrep over grep. Add trailing `:'
- command. Some minor changes to keep it more in sync with sister
- test `subdir5.test'.
- * tests/subdir5.test: Refactored and modified to minimize diffs
- with sister test `subdir8.test'.
+ * tests/subdir5.test: Make grepping of Makefile.in (in topdir
+ and in subdirs) stricter. Some minor changes to keep it more
+ in sync with the related test `subdir8.test'.
+ * tests/subdir8.test: Likewise (but with the related test being
+ `subdir5.test' here).
* tests/subdir6.test: Cosmetic change in spacing.
* tests/subdir9.test: Define and use new variable `$distdir'. Add
trailing `:' command.
diff --git a/tests/subdir5.test b/tests/subdir5.test
index 0709440..ce60e9b 100755
--- a/tests/subdir5.test
+++ b/tests/subdir5.test
@@ -22,6 +22,7 @@
# This test assumes that the `make' utility is able to start
# over and reload Makefiles which have been remade (a non-POSIX feature).
+# See also the related test subdir8.test.
required='GNUmake gcc'
. ./defs || Exit 1
@@ -30,12 +31,9 @@ set -e
cat >> configure.in << 'END'
AC_PROG_CC
AM_PROG_CC_C_O
-m4_include([confiles.m4])
AC_OUTPUT
END
-: > confiles.m4
-
cat > Makefile.am << 'END'
bin_PROGRAMS = wish
wish_SOURCES = a.c
@@ -56,7 +54,7 @@ $AUTOMAKE --include-deps --copy --add-missing
./configure
$MAKE
-# Now add a new directory.
+# Now add new directories.
#
# We shouldn't need to $sleep here: configure ensures that files
# generated by it are newer than configure. Thus, even if
@@ -64,30 +62,38 @@ $MAKE
# below has the same timestamp as Makefile.in, the latter should
# be rebuilt due to its dependency on configure.in.
-mkdir maude
+# First we add a new directory by, modifying configure.in directly.
+# We update configure.in *before* updating sub/Makefile.am; subdir8.test
+# do it in the other way: it updates confiles.m4 (which is m4_included by
+# configure.in there) after Makefile.am.
-# Update confiles.m4 *before* updating sub/Makefile.am.
-# (subdir8.test do it in the other way: it updates confiles.m4
-# after Makefile.am)
-cat >> confiles.m4 << 'END'
-AC_CONFIG_FILES([maude/Makefile])
-END
+sed <configure.in >configure.tmp -e '/^AC_OUTPUT$/i\
+AC_CONFIG_FILES([maude/Makefile])\
+m4_include([confile.m4])'
+mv -f configure.tmp configure.in
+
+cat configure.in # might be useful for debugging
+
+: > confile.m4
+
+mkdir maude
cat > maude/Makefile.am << 'END'
include_HEADERS = foo.h
END
-echo 'SUBDIRS = maude' >> Makefile.am
-
: > maude/foo.h
+echo 'SUBDIRS = maude' >> Makefile.am
+
# We want a simple rebuild to create maude/Makefile automatically.
$MAKE
test -f maude/Makefile
-# Add yet another directory
+# Then we add a new directory by modifying a file included (through
+# `m4_include') by configure.in.
mkdir maude2
-cat >> confiles.m4 << 'END'
+cat >> confile.m4 << 'END'
AC_CONFIG_FILES([maude2/Makefile])
AC_SUBST([GREPME])
END
@@ -97,8 +103,8 @@ echo 'SUBDIRS += maude2' >> Makefile.am
# We want a simple rebuild to create maude2/Makefile and update
# all other Makefiles automatically.
$MAKE
-$FGREP GREPME Makefile
-$FGREP GREPME maude/Makefile
-$FGREP GREPME maude2/Makefile
+grep '^GREPME =' Makefile
+grep '^GREPME =' maude/Makefile
+grep '^GREPME =' maude2/Makefile
:
diff --git a/tests/subdir8.test b/tests/subdir8.test
index 3a79946..093fac8 100755
--- a/tests/subdir8.test
+++ b/tests/subdir8.test
@@ -21,6 +21,7 @@
# This test assumes that the `make' utility is able to start
# over and reload Makefiles which have been remade (a non-POSIX feature).
+# See also the related test subdir5.test.
required='GNUmake gcc'
. ./defs || Exit 1
@@ -66,7 +67,7 @@ $AUTOMAKE --copy --add-missing
./configure
$MAKE
-# Now add a new directory.
+# Now add new directories.
#
# We shouldn't need to $sleep here: configure ensures that files
# generated by it are newer than configure. Thus, even if
@@ -74,6 +75,11 @@ $MAKE
# below has the same timestamp as Makefile.in, the latter should
# be rebuilt due to its dependency on configure.in.
+# The first step users typically do when adding a new subdir is
+# editing configure.in. That is already tested by subdir5.test,
+# though, so here we try to just edit a file that is included by
+# configure.in, without touching configure.in itself.
+
mkdir sub/maude
cat > sub/maude/Makefile.am << 'END'
include_HEADERS = foo.h
@@ -86,9 +92,8 @@ echo 'SUBDIRS = maude' >> sub/Makefile.am
mkdir maude
: > maude/Makefile.am
-# Update confiles.m4 *after* updating sub/Makefile.am.
-# (subdir5.test do it in the other way: it updates confiles.m4
-# before Makefile.am)
+# Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
+# it in the other way: it updates configure.in before Makefile.am.
echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
# We want a simple rebuild from sub/ to create sub/maude/Makefile
@@ -103,9 +108,10 @@ test -f sub/maude/Makefile
# the top-level directory.
echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
$MAKE
-$FGREP GREPME Makefile
-$FGREP GREPME maude/Makefile
-$FGREP GREPME sub/Makefile
-$FGREP GREPME sub/maude/Makefile
+
+grep '^GREPME =' Makefile
+grep '^GREPME =' maude/Makefile
+grep '^GREPME =' sub/Makefile
+grep '^GREPME =' sub/maude/Makefile
:
--
1.7.1