+2011-08-09 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ test defs: test directory creation more configurable
+ After this change, the individual tests will be able to tell
+ `./defs' whether or not to create a temporary test directory
+ for them, and if yes, whether or not to pre-populate it.
+ * tests/defs: Only create the temporary test directory if the
+ variable `$am_create_testdir' is not set to "no". In this
+ case, only pre-populate it if that variable is not set to
+ `$empty'.
+ * tests/defs-static.in: Check that `$am_create_testdir' is not
+ exported in the environment.
+ * tests/self-check-env-sanitize.test: Update.
+ * tests/self-check-dir.test: Extend, and make deeper and more
+ robust.
+ * tests/README (Section "Writing test cases" subsection "Do"):
+ Update.
+ * tests/autodist.test: Set `$am_create_testdir' instead of
+ removing by hand files created by ./defs.
+ * tests/tap-doc2.test: Likewise.
+
2011-08-08 Stefano Lattarini <stefano.lattarini@gmail.com>
testsuite: more uses of the `seq_' function
should be very very few), set the shell variable `parallel_tests' to
"no" before including ./defs.
- ./defs sets a skeleton configure.in. If possible, append to this
- file. In some cases you'll have to overwrite it, but this should
- be the exception. Note that configure.in registers Makefile.in
- but do not output anything by default. If you need ./configure
- to create Makefile, append AC_OUTPUT to configure.in.
+ ./defs brings in some commonly required files, and sets a skeleton
+ configure.in. If possible, append to this file. In some cases
+ you'll have to overwrite it, but this should be the exception. Note
+ that configure.in registers Makefile.in but do not output anything by
+ default. If you need ./configure to create Makefile, append AC_OUTPUT
+ to configure.in. In case you don't want ./defs to pre-populate your
+ test directory (which is a rare occurrence), set `$am_create_destdir'
+ to "empty" before sourcing ./defs.
By default, the testcases are run with the `errexit' shell flag on,
to make it easier to catch failures you might not have thought of.
# Related to automake bug#7819.
# Keep this test in sync with sister test `autodist-subdir.test'.
+am_create_testdir=empty
. ./defs || Exit 1
-# Ensure we are run from the right directory.
-# (The last thing we want is to delete some random user files.)
-test -f ../defs-static && test -f ../defs || Exit 99
-rm -f *
-
cat > configure.in <<END
AC_INIT([$me], [1.0])
AC_CONFIG_AUX_DIR([.])
# Test scripts are free to override this if they need to.
distdir=$me-1.0
-# The subdirectory where the current test script will run and write its
-# temporary/data files. This will be created shortly, and will be removed
-# by the cleanup trap below if the test passes. If the test doesn't pass,
-# this directory will be kept, to facilitate debugging.
-testSubDir=$me.dir
-
-test ! -d $testSubDir || rm_rf_ $testSubDir
-mkdir $testSubDir || framework_failure_ "creating test subdirectory"
-
-cd ./$testSubDir
-
+# Set up the exit trap.
if test "$sh_errexit_works" = yes; then
trap 'exit_status=$?
set +e
unset signal
fi
-# Copy in some files we need.
-cp "$top_testsrcdir"/lib/install-sh "$top_testsrcdir"/lib/missing \
- "$top_testsrcdir"/lib/depcomp . \
- || framework_failure_ "fetching common files from lib/"
-
-# Build appropriate environment in test directory. Eg create
-# configure.in, touch all necessary files, etc.
-# Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
-# still produces a valid configure.ac. But then, tests running
-# config.status really need to append AC_OUTPUT.
-{
- echo "AC_INIT([$me], [1.0])"
- if test x"$parallel_tests" = x"yes"; then
- echo "AM_INIT_AUTOMAKE([parallel-tests])"
- else
- echo "AM_INIT_AUTOMAKE"
+# Create and populate the temporary directory, if and as required.
+if test x"$am_create_testdir" = x"no"; then
+ testSubDir=
+else
+ # The subdirectory where the current test script will run and write its
+ # temporary/data files. This will be created shortly, and will be removed
+ # by the cleanup trap below if the test passes. If the test doesn't pass,
+ # this directory will be kept, to facilitate debugging.
+ testSubDir=$me.dir
+ test ! -d $testSubDir || rm_rf_ $testSubDir
+ mkdir $testSubDir || framework_failure_ "creating test subdirectory"
+ cd ./$testSubDir
+ if test x"$am_create_testdir" != x"empty"; then
+ cp "$top_testsrcdir"/lib/install-sh "$top_testsrcdir"/lib/missing \
+ "$top_testsrcdir"/lib/depcomp . \
+ || framework_failure_ "fetching common files from lib/"
+ # Build appropriate environment in test directory. E.g., create
+ # configure.in, touch all necessary files, etc. Don't use AC_OUTPUT,
+ # but AC_CONFIG_FILES so that appending still produces a valid
+ # configure.in. But then, tests running config.status really need
+ # to append AC_OUTPUT.
+ {
+ echo "AC_INIT([$me], [1.0])"
+ if test x"$parallel_tests" = x"yes"; then
+ echo "AM_INIT_AUTOMAKE([parallel-tests])"
+ else
+ echo "AM_INIT_AUTOMAKE"
+ fi
+ echo "AC_CONFIG_FILES([Makefile])"
+ } > configure.in
fi
- echo "AC_CONFIG_FILES([Makefile])"
-} >configure.in
+fi
## ---------------- ##
## Ready to go... ##
required \
use_tap \
parallel_tests \
+ am_create_testdir \
test_prefer_config_shell \
original_AUTOMAKE \
original_ACLOCAL \
# Sanity check for the automake testsuite.
# Check that tests using `./defs' create a proper temporary directory,
-# and run in it.
+# and run in it. Also check that we can prevent the pre-population
+# and the creation of such directory if we want.
. ./defs-static || exit 1
set -ex
-
AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
-this=S_dir
-outcome=:
-pwd
+# This needs to be consistent with what $SHELL deems to be the
+# current working directory.
+cwd=`$SHELL -c 'pwd'` || exit 99
+echo "$cwd"
+
+rm -f _self.tmp
-rm -f $this.tmp
+st=0
+$SHELL -c '
+ . ./defs || Exit 1
+ pwd; ls -l; # For debugging.
+ : > _self.tmp
+ test -f install-sh
+ test -f configure.in
+ case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac
+' _self.test || st=1
+test -f _self.tmp && { rm -f _self.tmp; st=1; }
+test $st -eq 0 || exit 1
-$SHELL -c "
+st=0
+$SHELL -c '
+ am_create_testdir=empty
. ./defs || Exit 1
- : > $this.tmp
- case \`pwd\` in '`pwd`'/$this.dir);; *) Exit 1;; esac
-" $this.test || outcome=false
+ pwd; ls -l; # For debugging.
+ ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1
+ : > _self.tmp
+ case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac
+ :
+' _self.test || st=1
+test -f _self.tmp && { rm -f _self.tmp; st=1; }
+test $st -eq 0 || exit 1
-test -f $this.tmp && { rm -f $this.tmp; outcome=false; }
+$SHELL -c '
+ am_create_testdir=no
+ . ./defs || Exit 1
+ test -f self-check-dir.test
+ case `pwd` in '"$cwd"');; *) Exit 1;; esac
+' _self.test || exit 1
-$outcome
+:
parallel_tests
required
use_tap
+ am_create_testdir
test_prefer_config_shell
original_AUTOMAKE
original_ACLOCAL
# See section "Using the TAP test protocol", subsection "Use TAP
# with the Automake test harness".
+am_create_testdir=empty
parallel_tests=yes
. ./defs || Exit 1
-# Ensure we are run from the right directory.
-# (The last thing we want is to delete some random user files.)
-test -f ../defs-static && test -f ../defs || Exit 99
-rm -f *
-
cat > Makefile.am <<'END'
TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver
TESTS = foo.test bar.test baz.test