+ 2011-03-01 Peter Rosin <peda@lysator.liu.se>
+
+ test defs: unindent without temporary file
+ * tests/defs.in (commented_sed_unindent_prog): Commented Sed program
+ that strips the "proper" amount of leading whitespace.
+ (unindent): Lazily strip comments from the above program and use it
+ to unindent without using a temporary file.
+
+ 2011-02-26 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ libtool: suggest LT_INIT if LTLIBRARIES primary is used
+ When the LTLIBRARIES primary was used, but $(LIBTOOL) wasn't
+ defined, automake suggested to add a call to AC_PROG_LIBTOOL
+ in configure.ac. But that macro is deprecated since Libtool
+ version 1.9b (2004-08-29), in favor of the newer LT_INIT. So
+ suggest the use of this latter macro instead.
+ * lib/Automake/Variable.pm (%_am_macro_for_var): Pair 'LIBTOOL'
+ with 'LT_INIT', not with 'AC_PROG_LIBTOOL'.
+ * libtool4.test: Adjust and extend. Also, add a call to macro
+ AC_PROG_CC in configure.in, to help ensuring that automake does
+ not fail for the wrong reasons.
+ * ltinit.test: New test, ensure that automake's libtool support
+ works with LT_INIT-based interface.
+ Thanks to Jack Kelly for the suggestion.
+
+2011-02-25 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tests: add testcases sanity-checking the testsuite
+ Helper subroutines, variables and other pieces of code defined
+ in the `tests/defs' and used by many testcases are non-obvious,
+ and tricky to get to work portably; but until now, they weren't
+ tested at all in a clear and self-contained way.
+ This change should remedy to the situation.
+ * tests/self-check-cleanup.test: New test, check removal of
+ temporary test working directory by `./defs'.
+ * tests/self-check-dir.test: New test, check that tests using
+ `./defs' create a proper temporary directory, and run in it.
+ * tests/self-check-exit.test: New test, check that, in case of
+ failing commands, the correct exit status is passed to the exit
+ trap installed by the `./defs' script.
+ * tests/self-check-is_newest.test: New test, checking the
+ `is_newest' subroutine.
+ * tests/self-check-me.test: New test, checking that $me gets
+ defined automatically by `tests/defs' if not set, and that it
+ can be overridden from either the shell or the environment.
+ * tests/self-check-sanity.test: New test, check that the sanity
+ checks performed by the `tests/defs' script works correctly.
+ * tests/self-check-unindent.test: New test, checking the
+ `unindent' subroutine.
+ * tests/Makefile.am (TESTS): Update.
+
2011-02-20 Stefano Lattarini <stefano.lattarini@gmail.com>
tests: tempdirs with restrictive permissions are cleaned correctly
# is defined initially, so that saving and restoring $IFS works.
IFS=$sp$tab$nl
-# Ensure we are running from the right directory.
-test -f ./defs || {
- echo "defs: not found in current directory" 1>&2
- exit 1
+# Ensure $testsrcdir is set correctly.
+test -f "$testsrcdir/defs-static.in" || {
+ echo "$me: $testsrcdir/defs-static.in not found, check \$testsrcdir" >&2
+ exit 99
+}
+
+# Ensure $testbuilddir is set correctly.
+test -f "$testbuilddir/defs-static" || {
+ echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2
+ exit 99
+}
+
+# Unset some MAKE... variables that may cause $MAKE to act like a
+# recursively invoked sub-make. Any $MAKE invocation in a test is
+# conceptually an independent invocation, not part of the main
+# 'automake' build.
+unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
+# Unset verbosity flag.
+unset V
+# Also unset variables that will let `make -e install' divert
+# files into unwanted directories.
+unset DESTDIR
+unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
+unset htmldir includedir infodir libdir libexecdir localedir mandir
+unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
+# The tests call `make -e' but we do not want $srcdir from the environment
+# to override the definition from the Makefile.
+unset srcdir
+# Also unset variables that control our test driver. While not
+# conceptually independent, they cause some changed semantics we
+# need to control (and test for) in some of the tests to ensure
+# backward-compatible behavior.
+unset TESTS_ENVIRONMENT
+unset DISABLE_HARD_ERRORS
+unset TESTS
+unset TEST_LOG_COMPILER
+unset TEST_LOGS
+unset RECHECK_LOGS
+unset VERBOSE
+
+
+## ---------------------------- ##
+## Auxiliary shell functions. ##
+## ---------------------------- ##
+
+# We use a trap below for cleanup. This requires us to go through
+# hoops to get the right exit status transported through the signal.
+# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit ()
+{
+ set +e
+ (exit $1)
+ exit $1
+}
+
+# is_newest FILE FILES
+# --------------------
+# Return false if any file in FILES is newer than FILE.
+# Resolve ties in favor of FILE.
+is_newest ()
+{
+ is_newest_files=`find "$@" -newer "$1"`
+ test -z "$is_newest_files"
+}
+
+# AUTOMAKE_run status [options...]
+# --------------------------------
+# Run Automake with OPTIONS, and fail if automake
+# does not exit with STATUS.
+AUTOMAKE_run ()
+{
+ expected_exitcode=$1
+ shift
+ exitcode=0
+ $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
+ cat stderr >&2
+ cat stdout
+ test $exitcode = $expected_exitcode || Exit 1
}
-if test -z "$srcdir"; then
- # compute $srcdir.
- srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
- test "$srcdir" = $0 && srcdir=.
-else :; fi
+# AUTOMAKE_fails [options...]
+# ---------------------------
+# Run Automake with OPTIONS, and fail if automake
+# does not exit with STATUS.
+AUTOMAKE_fails ()
+{
+ AUTOMAKE_run 1 ${1+"$@"}
+}
-# Ensure $srcdir is set correctly.
-test -f "$srcdir/defs.in" || {
- echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
- exit 1
++commented_sed_unindent_prog='
++ /^$/b # Nothing to do for empty lines.
++ x # Get x<indent> into pattern space.
++ /^$/{ # No prior x<indent>, go prepare it.
++ g # Copy this 1st non-blank line into pattern space.
++ s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x<indent> in pattern space.
++ } # Now: x<indent> in pattern and <line> in hold.
++ G # Build x<indent>\n<line> in pattern space, and
++ h # duplicate it into hold space.
++ s/\n.*$// # Restore x<indent> in pattern space, and
++ x # exchange with the above duplicate in hold space.
++ s/^x\(.*\)\n\1// # Remove leading <indent> from <line>.
++ s/^x.*\n// # Restore <line> when there is no leading <indent>.
++'
++
+# unindent [input files...]
+# -------------------------
+# Remove the "proper" amount of leading whitespace from the given files,
+# and output the result on stdout. That amount is determined by looking
+# at the leading whitespace of the first non-blank line in the input
+# files. If no input file is specified, standard input is implied.
+unindent ()
+{
- cat ${1+"$@"} > deindent.tmp
- indentation=`sed <deindent.tmp -n "
- /[^ $tab].*$/{
- s///p
- q
- }"`
- sed "s/^$indentation//" deindent.tmp
- rm -f deindent.tmp
++ if test x"$sed_unindent_prog" = x; then
++ sed_unindent_prog=`echo "$commented_sed_unindent_prog" | sed -e "s/ *# .*//"`
++ fi
++ sed "$sed_unindent_prog" ${1+"$@"}
}
-me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
-
-APIVERSION='@APIVERSION@'
-PATH_SEPARATOR='@PATH_SEPARATOR@'
-
-# Make sure we override the user shell.
-SHELL='@SHELL@'
-export SHELL
-# User can override various tools used.
-test -z "$PERL" && PERL='@PERL@'
-test -z "$MAKE" && MAKE=make
-test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
-test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
-test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
-test -z "$MISSING" && MISSING=`pwd`/../lib/missing
-# Use -Werror because this also turns some Perl warnings into error.
-# (Tests for which this is inappropriate should use -Wno-error.)
-test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror"
-# Extra flags to pass to aclocal before all other flags added by this script.
-ACLOCAL_TESTSUITE_FLAGS=
-export ACLOCAL_TESTSUITE_FLAGS
-
-# See how Automake should be run. We put --foreign as the default
-# strictness to avoid having to create lots and lots of files. A test
-# can override this by specifying a different strictness. Use -Wall
-# -Werror by default. Tests for which this is inappropriate
-# (e.g. when testing that a warning is enabled by a specific switch)
-# should use -Wnone or/and -Wno-error
-test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall"
-
-PATH="`pwd`$PATH_SEPARATOR$PATH"
+
+## ----------------------------------------------------------- ##
+## Checks for required tools, and additional setups (if any) ##
+## required by them. ##
+## ----------------------------------------------------------- ##
+
+# Print it here, so that the user will see it also if the test
+# will be skipped due to some tool missing in $PATH itslef.
echo "$PATH"
-# Some shells forget to export modified environment variables.
-# (See note about `export' in the Autoconf manual.)
-export PATH
+# Look for (and maybe set up) required tools and/or system features; skip
+# the current test if they are not found.
for tool in : $required
do
# Check that each required tool is present.