/mts/libmts.a
/sbr/*.a
/sbr/sigmsg.h
-/test/testbuild/
-/test/testinstall/
+/test/testdir
/uip/ali
/uip/anno
/uip/ap
##
## nmh _does_ have a test suite!
##
-testdir = $(srcdir)/test
-## It might be nice to configure testinstall and testbuild
-## directories, but for now they're hard-coded here and in the test
-## scripts.
-## And it would be easier to clean up if tests were launched from a
-## tmp directory, and/or each test cleaned up after itself on
-## successful completion.
-##MOSTLYCLEANFILES = test/testinstall/*.actual* test/testinstall/*.expected* \
-## test/testinstall/*.replgroupcomps test/testinstall/*.draft \
-## test/testinstall/,*.draft*
-
-mostlyclean-local:
- rm -rf test/testinstall
- rm -rf test/testbuild
+
+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)
+##
+## Important note: the "cleanup" test should always be last
+##
+TESTS = test/bad-input/test-header test/folder/test-create \
+ test/folder/test-total test/inc/test-deb359167 test/inc/test-eom-align \
+ test/manpages/test-manpages test/mhbuild/test-forw \
+ test/mhshow/test-cte-binary test/mhshow/test-qp \
+ test/mhshow/test-subpart test/new/test-basic test/pick/test-stderr \
+ test/repl/test-if-str test/scan/test-scan \
+ test/whatnow/test-attach-detach test/whatnow/test-cd \
+ test/whatnow/test-ls test/cleanup
+
+check_SCRIPTS = test/common.sh
##
## Stuff that should be cleaned via "make clean"
etc/mhn.defaults man/man.sed $(man_MANS)
clean-local:
@rm -rf RPM a.out.DSYM uip/a.out.DSYM
- @$(testdir)/teardown-test
+ @rm -rf test/testdir
##
## Stuff that should be cleaned via "make maintainer-clean"
man/rcvpack.man man/rcvstore.man man/rcvtty.man man/refile.man \
man/repl.man man/rmf.man man/rmm.man man/scan.man man/send.man \
man/sendfiles.man man/show.man man/slocal.man man/sortm.man \
- man/unseen.man man/whatnow.man man/whom.man test/common.sh.in \
- test/README test/runalltests test/runtest test/setup-test \
- test/teardown-test test/tests
+ man/unseen.man man/whatnow.man man/whom.man test/README $(TESTS) \
+ test/inc/deb359167.mbox test/inc/fromline.txt \
+ test/inc/msgheader.txt test/inc/filler.txt test/inc/md5sums
##
## These are all of the definitions for each of the programs listed above.
.man.$(manext8):
$(SED) -f man/man.sed $< > $@
-test: all
- @$(testdir)/runalltests
-.PHONY: test
-
## Don't include commit hashes in ChangeLog.
ChangeLog:
@[ -d .git ] && git --no-pager log --abbrev-commit | \
* for a test pass: exit with status 0
* where a test has been skipped (perhaps because it depends on an
external program which can't be found): print "Test $0 SKIP (reason)"
- and exit with status 120
+ and exit with status 77
* for a test fail: exit with some status other than 0 or 120
-The Suite is arranged as such:
+The Suite is a re-worked version of the original test suite; it now is
+designed to work with Automake. To run these tests you can do "make check"
+via the top-level Makefile. This is also done automatically via
+"make distcheck".
-setup-test
- Create the unit test framework. This will re-generate your configure
- script and make files.
+If you wish to write a new test, here are the steps:
-teardown-test
- Remove the temporary files created as part of the unit tests.
+- 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).
-runtest
- Run a single test.
+- Your path will be set up to find the locations of the test nmh binaries.
-runalltests
- Run all tests in the suite
+- Add your script to the TESTS variable in the toplevel Makefile.am.
-tests
- Directory containing the tests. All files found in this and all
- subsequent directories which have the name test-* will be treated as a
- single test.
+- 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.
-Complex tests may be given their own directory as long as there is a file
-named 'test-*' in the directory which will launch the test.
+- 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'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
# TODO: Move to a common file tests can source; need more framework...
failed=0
check() {
--- /dev/null
+#!/bin/sh
+#
+# This exists so "make check" will always clean up the "inst" directory
+# after a run, even if tests fail. That way if you fix a problem and do
+# 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'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
+rm -rf ${MH_INST_DIR}
# Common helper routines for test shell scripts -- intended to be sourced by them
+# @configure_input@
output_md5()
{
{
WHY="$1"
echo "$Test $0 SKIP ($WHY)"
- exit 120
+ exit 77
}
# portable implementation of 'which' utility
{
printf "100%%\n"
}
+
+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}
+
+ if [ -z "${srcdir}" ]; then
+ echo "srcdir not set; aborting"
+ exit 1
+ fi
+
+ #
+ # Only do this once
+ #
+
+ if [ ! -d ${MH_INST_DIR}${bindir} ]; then
+ (cd ${MH_OBJ_DIR} && make DESTDIR=${MH_INST_DIR} install) || exit 1
+ fi
+
+ # clean old test data
+ trap "rm -rf $MH_TEST_DIR/Mail; exit \$status" 0
+ # setup test data
+ mkdir $MH_TEST_DIR/Mail || exit 1
+ cat > $MH <<EOF || exit 1
+Path: ${MH_TEST_DIR}/Mail
+mhlproc: ${MH_OBJ_DIR}/uip/mhl
+EOF
+
+ for f in MailAliases components digestcomps distcomps forwcomps mhl.body \
+ mhl.digest mhl.format mhl.forward mhl.headers mhl.reply \
+ rcvdistcomps replcomps replgroupcomps scan.MMDDYY \
+ scan.YYYYMMDD scan.default scan.mailx scan.nomime scan.size \
+ scan.time scan.timely scan.unseen
+ do
+ cp ${srcdir}/etc/${f} ${MH_TEST_DIR}/Mail || exit 1
+ done
+
+ for f in mhn.defaults mts.conf
+ do
+ cp ${MH_OBJ_DIR}/etc/${f} ${MH_TEST_DIR}/Mail || exit 1
+ done
+
+ folder -create +inbox > /dev/null
+ # create 10 basic messages
+ for i in 1 2 3 4 5 6 7 8 9 10;
+ do
+ cat > $MH_TEST_DIR/Mail/inbox/$i <<EOF || exit 1
+From: Test$i <test$i@example.com>
+To: Some User <user@example.com>
+Date: Fri, 29 Sep 2006 00:00:00
+Subject: Testing message $i
+
+This is message number $i
+EOF
+ done
+}
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
folder -create +testfolder > /dev/null
if [ ! -d "$MH_TEST_DIR/Mail/testfolder" ]; then
exit 1
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
output=`folder -total +inbox`
if test x"$output" != x'TOTAL = 10 messages in 1 folder.' ; then
exit 1
# Test a variant of a mailbox which caused debian bug 359167.
set -e
-. $MH_TEST_COMMON
+. ${MH_TEST_COMMON}
-THISDIR="tests/inc"
+setup_test
+
+THISDIR="${srcdir}/test/inc"
require_prog valgrind
set -e
-. $MH_TEST_COMMON
+. ${MH_TEST_COMMON}
-THISDIR="tests/inc"
+setup_test
+
+THISDIR="${srcdir}/test/inc"
if [ ! -z "$VALGRIND_ME" ]; then
require_prog valgrind
#
######################################################
-. $MH_TEST_COMMON
+. ${MH_TEST_COMMON}
+
+setup_test
require_prog groff
-cd $MH_TEST_DIR/share/man
+cd ${MH_INST_DIR}${mandir} || exit 1
# groff will still exit with status zero even if warnings
# were emitted, so we have to jump through hoops to
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
# TODO: Move to a common file tests can source; need more framework...
failed=0
check() {
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
set -e
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
set -e
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
#!/bin/sh
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
# TODO: Move to a common file tests can source; need more framework...
failed=0
check() {
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
expected_err=$MH_TEST_DIR/$$.expected_err
expected_out=$MH_TEST_DIR/$$.expected_out
actual_err=$MH_TEST_DIR/$$.actual_err
cat /dev/null > $expected_out
pick -a > $actual_out 2> $actual_err
-diff -u $expected_err $actual_err
-diff -u $expected_out $actual_out
+diff -u $expected_err $actual_err || exit 1
+diff -u $expected_out $actual_out || exit 1
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
# create test replgroupcomps
form=$MH_TEST_DIR/$$.replgroupcomps
cat > $form <<EOF
> This is message number 1
EOF
-repl -editor true -format -form $form -group -nocc me -nowhatnowproc 1
+repl -editor true -format -form $form -group -nocc me -nowhatnowproc 1 || exit 1
diff -u $expected $actual
+++ /dev/null
-#!/bin/sh
-
-# Get full pathnames that we'll need.
-cd `dirname $0`
-testdir=`pwd`
-
-# Always run setup-test in case the code or configuration has changed.
-./setup-test
-
-status=0
-
-# Note that we ignore *~ files as these are probably editor backups.
-for i in `find . -name 'test-*[!~]' -type f`
-do
- $testdir/runtest $i || status=$?
-done
-
-exit $status
+++ /dev/null
-#!/bin/sh
-
-status=1
-
-[ $# -eq 1 ] || echo "usage: $0 "'<testname>'
-
-# Get full pathnames that we'll need.
-cd `dirname $0`
-
-export MH_TEST_DIR=`pwd`/testinstall
-export MH=$MH_TEST_DIR/Mail/.mh_profile
-export PATH=$MH_TEST_DIR/bin:$PATH
-export MH_TEST_COMMON=$PWD/common.sh
-
-[ -d $MH_TEST_DIR ] || ./setup-test
-
-# clean old test data
-trap "rm -rf $MH_TEST_DIR/Mail; exit \$status" 0
-# setup test data
-rm -rf $MH_TEST_DIR/Mail
-mkdir $MH_TEST_DIR/Mail
-echo "Path: $MH_TEST_DIR/Mail" > $MH
-folder -create +inbox > /dev/null
-# create 10 basic messages
-for i in 1 2 3 4 5 6 7 8 9 10;
-do
- cat > $MH_TEST_DIR/Mail/inbox/$i <<EOF
-From: Test$i <test$i@example.com>
-To: Some User <user@example.com>
-Date: Fri, 29 Sep 2006 00:00:00
-Subject: Testing message $i
-
-This is message number $i
-EOF
-done
-
-# now run the test
-set +e
-/bin/sh $1
-return_value=$?
-set -e
-
-if [ $return_value -eq 0 ]; then
- echo Test $1 PASS
- status=0
-elif [ $return_value -eq 120 ]; then
- # indicates test was skipped (eg needed program not found)
- # test itself should have printed a message about this,
- # so print nothing here.
- status=0
-else
- echo Test $1 FAIL
-fi
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
10 09/29 Test10 Testing message 10<<This is message number 10 >>
EOF
-scan -width 80 +inbox > $actual
+scan -width 80 +inbox > $actual || exit 1
diff -u $expected $actual
+++ /dev/null
-#!/bin/sh
-#
-# Copy our sources and configuration, but change the installation
-# prefix so that we can test with a completely independent
-# installation.
-
-# Get full pathnames that we'll need. Assumes that this script is
-# located in the nmh test subdirectory.
-cd `dirname $0`
-testdir=`pwd`
-srcdir=`dirname $testdir`
-builddir=$testdir/testbuild
-installdir=$testdir/testinstall
-
-#### Set up builddir.
-[ -d $builddir ] || mkdir -p $builddir
-cd $builddir
-
-#### Expedient way to copy the sources and configuration.
-if rsync -h >/dev/null 2>&1; then
- rsync -a $srcdir/ --exclude .git --exclude test --exclude .deps \
- --exclude '*.gz' --exclude '*.*o' .
-else
- (cd $srcdir && tar cf - \
- `find . -name .git -prune -o -name test -prune -o -name .deps -prune -o \
- \( ! -type d ! -name '*.gz' ! -name '*.*o' -print \)`) | \
- tar xpf -
-fi
-
-#### Set up new configuration.
-#### Put it in a file so we don't have to mess with shell quoting. It
-#### would get tricky with configure options that can contain embedded
-#### spaces, such as --enable-masquerade and --with-smtpservers.
-reconfig=reconfig-for-test
-echo 'set '/bin/sh' './configure' \' > $reconfig
-#### Configure allows multiple --prefix but ignores all but the last.
-#### So add the one we want to use. This is easier than trying to change
-#### an existing --prefix, esp. if it has quoted characters.
-echo $(./config.status --config) \'--prefix="$installdir"\' >> $reconfig
-echo 'exec "$@"' >> $reconfig
-
-echo configuring the test installation in "$installdir" . . .
-/bin/sh $reconfig > /dev/null
-
-echo building the test installation . . .
-make install > /dev/null
+++ /dev/null
-#!/bin/sh
-
-# Get full pathnames that we'll need.
-testdir=`dirname $0`
-builddir=$testdir/testbuild
-testinstalldir=$testdir/testinstall
-
-rm -rf $builddir $testinstalldir
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
set -e
cd "$MH_TEST_DIR"
echo "alist" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
set -e
-diff -u $expectederr $actualerr
+diff -u $expectederr $actualerr || exit 1
diff -u $expected $actual
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
set -e
SPDIR="$MH_TEST_DIR/foo's bar"
rm -rf "$SPDIR"
# watch the quoting -- shell and printf and then the shell run inside whatnow
printf "cd $MH_TEST_DIR/foo\\\\'s\\\\ bar\npwd\n" | whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true
-diff -u $expectederr $actualerr
+diff -u $expectederr $actualerr || exit 1
diff -u $expected $actual
#
######################################################
+if [ -z "${MH_TEST_COMMON}" ]; then
+ echo "MH_TEST_COMMON not set; try running via 'make check'"
+fi
+
+. ${MH_TEST_COMMON}
+
+setup_test
+
set -e
SPDIR="$MH_TEST_DIR/foo's bar"
rm -rf "$SPDIR"
# NB use of sort as the order of output of ls is not guaranteed
echo 'ls' | whatnow -noedit -prompt '' 2> "$actualerr" | sort > "$actual"
-diff -u $expectederr $actualerr
+diff -u $expectederr $actualerr || exit 1
diff -u $expected $actual