/mts/libmts.a
/sbr/*.a
/sbr/sigmsg.h
+/test/testbuild
+/test/testinstall
/uip/ali
/uip/anno
/uip/ap
auxexecdir = @libdir@
##
+## 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* \*
+
+##
## Stuff that should be cleaned via "make clean"
##
CLEANFILES = config/version.c sbr/sigmsg.h etc/mts.conf etc/sendfiles \
etc/mhn.defaults man/man.sed $(man_MANS)
clean-local:
@rm -rf RPM a.out.DSYM uip/a.out.DSYM
+ @$(testdir)/teardown-test
##
## Stuff that should be cleaned via "make maintainer-clean"
.man.$(manext8):
$(SED) -f man/man.sed $< > $@
+test: all
+ @test -d $(testdir)/testinstall || $(testdir)/setup-test
+ @$(testdir)/runalltests
+.PHONY: test
+
## Don't include commit hashes in ChangeLog.
ChangeLog:
@[ -d .git ] && git --no-pager log --abbrev-commit | \
#!/bin/sh
-# Note that we ignore *~ files as these are probably editor backups
-for i in `find tests -name 'test-*[!~]' -type f`;
+status=0
+
+# Get full pathnames that we'll need.
+cd `dirname $0`
+testdir=`pwd`
+
+test -d testinstall || ./setup-test
+
+# Note that we ignore *~ files as these are probably editor backups.
+for i in `find . -name 'test-*[!~]' -type f`
do
- ./runtest $i
+ $testdir/runtest $i || status=$?
done
+
+exit $status
#!/bin/sh
-set -e
-
-if [ ! -e test-temp-dir ]; then
- echo "test-temp-dir not found: running setup-test"
- ./setup-test
-fi
+status=1
-export MH_TEST_DIR=`cat test-temp-dir`
+[ $# -eq 1 ] || echo "usage: $0 "'<testname>'
-if [ ! -e "$MH_TEST_DIR/bld/Makefile" ]; then
- echo "temporary directory missing or broken: running setup-test"
- ./setup-test
- export MH_TEST_DIR=`cat test-temp-dir`
-fi
+# 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
-rm -rf $MH_TEST_DIR/Mail
+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
return_value=$?
set -e
-if [ $return_value -eq 0 ] ; then
+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,
#!/bin/sh
+#
+# Copy our sources and configuration, but change the installation
+# prefix so that we can test with a completely independent
+# installation.
-set -e
+# 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
-if TEMPDIR=`cat test-temp-dir 2> /dev/null` \
- && [ -e $TEMPDIR/bld/Makefile ]; then
- (cd $TEMPDIR/bld && make all install)
- exit
+#### 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
-TEMPDIR=`mktemp -d /tmp/nmh-test-XXXXXXXX`
-echo $TEMPDIR > test-temp-dir
+#### 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
-cd ..
-if ! [ -e configure ]; then
- ./autogen.sh
-fi
-srcdir=$PWD
-mkdir $TEMPDIR/bld
-cd $TEMPDIR/bld
-$srcdir/configure --prefix=$TEMPDIR --with-locking=fcntl --enable-debug
-make install
+echo configuring the test installation in "$installdir" . . .
+/bin/sh $reconfig > /dev/null
+
+echo building the test installation . . .
+make install > /dev/null
#!/bin/sh
-rm -rf `cat test-temp-dir`
-rm -f test-temp-dir
+# Get full pathnames that we'll need.
+testdir=`dirname $0`
+builddir=$testdir/testbuild
+testinstalldir=$testdir/testinstall
+
+rm -rf $builddir $testinstalldir