2010-07-21 Stefano Lattarini <stefano.lattarini@gmail.com>
+ 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.
+
Modernize and improve test scripts `dist*.test'.
* tests/distcleancheck.test: Do not add useless `-e' option to
a $MAKE call. Extend test by grepping stderr of make.
#! /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
. ./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'
pkgdata_DATA =
END
-$ACLOCAL || Exit 1
+$ACLOCAL
$AUTOMAKE
+
+:
#! /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
./configure
env fail=1 $MAKE all clean
-Exit 0
+:
#! /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
. ./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'.
pkgdata_DATA =
END
-$ACLOCAL || Exit 1
+$ACLOCAL
$AUTOMAKE --gnu
+
+:
#! /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
. ./defs || Exit 1
+set -e
+
cat > Makefile.am << 'END'
bin_PROGRAMS = zardoz widdershins
zardoz_SOURCES = y.c x/z.c
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
+
+:
#! /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
. ./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'.
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
# continued line.
grep '^DIST_COMMON.*depcomp' lib/Makefile.in && Exit 1
-Exit 0
+:
#! /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
# 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
./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
+# does 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
$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
+
+:
#! /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
test -f sub/stamp-h1
$MAKE distclean
test -f sub/stamp-h1 && Exit 1
+
:
#! /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
mkdir obj
cat >>configure.in << 'END'
-AC_CONFIG_FILES(obj/Makefile)
+AC_CONFIG_FILES([obj/Makefile])
AC_OUTPUT
END
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
+
+:
#! /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
# 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
AC_OUTPUT
END
+echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
+
cat > Makefile.am << 'END'
SUBDIRS = sub
ACLOCAL_AMFLAGS = -I m4
./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'
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
# 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
+
+:
#! /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
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
+
+:
#! /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
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'.
$ACLOCAL
-
$AUTOCONF
-
$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu
./configure
# $MAKE -C lib foo.h
$MAKE
-Exit 0
+: