## nmh _does_ have a test suite!
##
-TESTS_ENVIRONMENT = MH_TEST_DIR=`pwd`/test/testdir \
- MH_TEST_COMMON=`pwd`/test/common.sh \
- MH_OBJ_DIR=`pwd` mandir=$(mandir) bindir=$(bindir) \
- sysconfdir=$(sysconfdir) auxexecdir=$(auxexecdir)
+TESTS_ENVIRONMENT = MH_OBJ_DIR=@abs_srcdir@ \
+ MH_TEST_DIR=@abs_srcdir@/test/testdir \
+ auxexecdir=$(auxexecdir) bindir=$(bindir) \
+ mandir=$(mandir) sysconfdir=$(sysconfdir)
##
## Important note: the "cleanup" test should always be last
##
via the top-level Makefile. This is also done automatically via
"make distcheck".
-If you wish to write a new test, here are the steps:
+WARNING: The test suite installs nmh and run the tests on that test
+installation. If you run tests individually, they will not remove
+that test installation or check to see if it remains up to date with
+your nmh workspace. You can run test/clean after a test to remove the
+test installation. "make check" will do that, so it is best to use
+it.
-- Make sure your test script sources common.sh (the location of this script
- is in the MH_TEST_COMMON environment variable and calls the setup_test
- shell function (the other scripts have examples of this).
+If you wish to write a new test script, here are the steps:
+
+- Make sure your test script sources $MH_OBJ_DIR/test/common.sh and
+ calls the setup_test shell function (the other scripts have examples
+ of this).
- Your path will be set up to find the locations of the test nmh binaries.
- Add your script to the TESTS variable in the toplevel Makefile.am.
+ By convention, test script names start with "test-", though that
+ is not a requirement.
- If you need additional files for your tests, be sure to add them to
the EXTRA_DIST variable in Makefile.am. Note that you should insure
- that you access these files relative to the ${srcdir} environment variable.
+ that you access these files relative to the $MH_OBJ_DIR environment variable.
- Verify that the test works with both "make check" and "make distcheck".
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# another "make check", you will get new binaries to test against.
#
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
-
-setup_test
+. "$MH_OBJ_DIR/test/common.sh"
rm -rf ${MH_INST_DIR}
# Common helper routines for test shell scripts -- intended to be sourced by them
# @configure_input@
+
+#### The following exported variables are set by "make check". Ensure
+#### that they are set here so that individual tests can be run
+#### outside of make. Requires that MH_OBJ_DIR be set on entry.
+test -z "$MH_TEST_DIR" && MH_TEST_DIR="$MH_OBJ_DIR/test/testdir"
+test -z "$prefix" && prefix=@prefix@
+test -z "$datarootdir" && datarootdir=@datarootdir@
+test -z "$exec_prefix" && exec_prefix=@exec_prefix@
+test -z "$auxexecdir" && auxexecdir="@libdir@"
+test -z "$bindir" && bindir="@bindir@"
+test -z "$mandir" && mandir="@mandir@"
+test -z "$sysconfdir" && sysconfdir="@sysconfdir@"
+export MH_TEST_DIR auxexecdir bindir mandir sysconfdir
+
+test -z "$MH_INST_DIR" && MH_INST_DIR=${MH_TEST_DIR}/inst
+export MH_INST_DIR
+
+
output_md5()
{
@MD5SUM@ $* | @MD5FMT@
setup_test ()
{
export MH=${MH_TEST_DIR}/Mail/.mh_profile
- export MH_INST_DIR=${MH_TEST_DIR}/inst
export MHMTSCONF=${MH_INST_DIR}${sysconfdir}/mts.conf
export PATH=${MH_INST_DIR}${bindir}:${PATH}
export MH_LIB_DIR=${MH_INST_DIR}${auxexecdir}
- if [ -z "${srcdir}" ]; then
- echo "srcdir not set; aborting"
- exit 1
- fi
-
#
- # Only do this once
+ # Only install once
#
-
if [ ! -d ${MH_INST_DIR}${bindir} ]; then
(cd ${MH_OBJ_DIR} && make DESTDIR=${MH_INST_DIR} install) || exit 1
fi
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# component functions
#
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# the localname entry out of the mts configuration file.
#
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# a particular email address is "mine" or not
#
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# the Signature profile entry, and via SIGNATURE environment variable.
#
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# Test a variant of a mailbox which caused debian bug 359167.
set -e
-. ${MH_TEST_COMMON}
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
-THISDIR="${srcdir}/test/inc"
+THISDIR="${MH_OBJ_DIR}/test/inc"
require_prog valgrind
set -e
-. ${MH_TEST_COMMON}
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
-THISDIR="${srcdir}/test/inc"
+THISDIR="${MH_OBJ_DIR}/test/inc"
if [ ! -z "$VALGRIND_ME" ]; then
require_prog valgrind
#
######################################################
-. ${MH_TEST_COMMON}
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
expected=$MH_TEST_DIR/$$.expected
set -e
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
set -e
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#!/bin/sh
-
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+######################################################
+#
+# Test many basic nmh capabilities.
+#
+######################################################
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
# TODO: Move to a common file tests can source; need more framework...
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test
#
######################################################
-if [ -z "${MH_TEST_COMMON}" ]; then
- echo "MH_TEST_COMMON not set; try running via 'make check'"
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi
-. ${MH_TEST_COMMON}
+. "$MH_OBJ_DIR/test/common.sh"
setup_test