From 6106441685a38400d9aa94ccb7218218102f941c Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 10 Feb 2012 23:09:03 -0500 Subject: [PATCH] Re-work the test suite so it now works with Automake (via "make check"). --- .gitignore | 3 +- Makefile.am | 44 +++++++++---------- test/README | 32 +++++++------- test/{tests => }/bad-input/test-header | 8 ++++ test/cleanup | 16 +++++++ test/common.sh.in | 61 ++++++++++++++++++++++++++- test/{tests => }/folder/test-create | 8 ++++ test/{tests => }/folder/test-total | 8 ++++ test/{tests => }/inc/deb359167.mbox | Bin 3324 -> 3324 bytes test/{tests => }/inc/filler.txt | 0 test/{tests => }/inc/fromline.txt | 0 test/{tests => }/inc/md5sums | 0 test/{tests => }/inc/msgheader.txt | 0 test/{tests => }/inc/test-deb359167 | 6 ++- test/{tests => }/inc/test-eom-align | 6 ++- test/{tests => }/manpages/test-manpages | 6 ++- test/{tests => }/mhbuild/test-forw | 8 ++++ test/{tests => }/mhshow/test-cte-binary | 7 +++ test/{tests => }/mhshow/test-qp | 8 ++++ test/{tests => }/mhshow/test-subpart | 8 ++++ test/{tests => }/new/test-basic | 7 +++ test/{tests => }/pick/test-stderr | 12 +++++- test/{tests => }/repl/test-if-str | 10 ++++- test/runalltests | 18 -------- test/runtest | 53 ----------------------- test/{tests => }/scan/test-scan | 10 ++++- test/setup-test | 46 -------------------- test/teardown-test | 8 ---- test/{tests => }/whatnow/test-attach-detach | 10 ++++- test/{tests => }/whatnow/test-cd | 10 ++++- test/{tests => }/whatnow/test-ls | 10 ++++- 31 files changed, 243 insertions(+), 180 deletions(-) rename test/{tests => }/bad-input/test-header (91%) mode change 100644 => 100755 create mode 100755 test/cleanup rename test/{tests => }/folder/test-create (73%) mode change 100644 => 100755 rename test/{tests => }/folder/test-total (65%) mode change 100644 => 100755 rename test/{tests => }/inc/deb359167.mbox (100%) rename test/{tests => }/inc/filler.txt (100%) rename test/{tests => }/inc/fromline.txt (100%) rename test/{tests => }/inc/md5sums (100%) rename test/{tests => }/inc/msgheader.txt (100%) rename test/{tests => }/inc/test-deb359167 (85%) mode change 100644 => 100755 rename test/{tests => }/inc/test-eom-align (98%) mode change 100644 => 100755 rename test/{tests => }/manpages/test-manpages (91%) mode change 100644 => 100755 rename test/{tests => }/mhbuild/test-forw (94%) mode change 100644 => 100755 rename test/{tests => }/mhshow/test-cte-binary (87%) mode change 100644 => 100755 rename test/{tests => }/mhshow/test-qp (89%) mode change 100644 => 100755 rename test/{tests => }/mhshow/test-subpart (89%) mode change 100644 => 100755 rename test/{tests => }/new/test-basic (96%) mode change 100644 => 100755 rename test/{tests => }/pick/test-stderr (71%) mode change 100644 => 100755 rename test/{tests => }/repl/test-if-str (85%) mode change 100644 => 100755 delete mode 100755 test/runalltests delete mode 100755 test/runtest rename test/{tests => }/scan/test-scan (85%) mode change 100644 => 100755 delete mode 100755 test/setup-test delete mode 100755 test/teardown-test rename test/{tests => }/whatnow/test-attach-detach (86%) mode change 100644 => 100755 rename test/{tests => }/whatnow/test-cd (81%) mode change 100644 => 100755 rename test/{tests => }/whatnow/test-ls (79%) mode change 100644 => 100755 diff --git a/.gitignore b/.gitignore index 159cacf..b65e540 100644 --- a/.gitignore +++ b/.gitignore @@ -45,8 +45,7 @@ a.out.DSYM/ /mts/libmts.a /sbr/*.a /sbr/sigmsg.h -/test/testbuild/ -/test/testinstall/ +/test/testdir /uip/ali /uip/anno /uip/ap diff --git a/Makefile.am b/Makefile.am index 1340639..e2aa952 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,20 +33,24 @@ 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* - -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" @@ -55,7 +59,7 @@ 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 + @rm -rf test/testdir ## ## Stuff that should be cleaned via "make maintainer-clean" @@ -184,9 +188,9 @@ EXTRA_DIST = config/version.sh sbr/sigmsg.awk etc/mts.conf.in etc/sendfiles.in \ 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. @@ -500,10 +504,6 @@ man/man.sed: Makefile .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 | \ diff --git a/test/README b/test/README index c61647e..3d7d478 100644 --- a/test/README +++ b/test/README @@ -9,28 +9,26 @@ the result by one of: * 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". diff --git a/test/tests/bad-input/test-header b/test/bad-input/test-header old mode 100644 new mode 100755 similarity index 91% rename from test/tests/bad-input/test-header rename to test/bad-input/test-header index b9e76a1..35d680a --- a/test/tests/bad-input/test-header +++ b/test/bad-input/test-header @@ -5,6 +5,14 @@ # ###################################################### +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() { diff --git a/test/cleanup b/test/cleanup new file mode 100755 index 0000000..82b2261 --- /dev/null +++ b/test/cleanup @@ -0,0 +1,16 @@ +#!/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} diff --git a/test/common.sh.in b/test/common.sh.in index c7d557a..4c7089c 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -1,4 +1,5 @@ # Common helper routines for test shell scripts -- intended to be sourced by them +# @configure_input@ output_md5() { @@ -9,7 +10,7 @@ test_skip () { WHY="$1" echo "$Test $0 SKIP ($WHY)" - exit 120 + exit 77 } # portable implementation of 'which' utility @@ -56,3 +57,61 @@ progress_done () { 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 < /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 < +To: Some User +Date: Fri, 29 Sep 2006 00:00:00 +Subject: Testing message $i + +This is message number $i +EOF + done +} diff --git a/test/tests/folder/test-create b/test/folder/test-create old mode 100644 new mode 100755 similarity index 73% rename from test/tests/folder/test-create rename to test/folder/test-create index 5b74b23..a3460ee --- a/test/tests/folder/test-create +++ b/test/folder/test-create @@ -5,6 +5,14 @@ # ###################################################### +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 diff --git a/test/tests/folder/test-total b/test/folder/test-total old mode 100644 new mode 100755 similarity index 65% rename from test/tests/folder/test-total rename to test/folder/test-total index ff29310..86b304f --- a/test/tests/folder/test-total +++ b/test/folder/test-total @@ -5,6 +5,14 @@ # ###################################################### +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 diff --git a/test/tests/inc/deb359167.mbox b/test/inc/deb359167.mbox similarity index 100% rename from test/tests/inc/deb359167.mbox rename to test/inc/deb359167.mbox diff --git a/test/tests/inc/filler.txt b/test/inc/filler.txt similarity index 100% rename from test/tests/inc/filler.txt rename to test/inc/filler.txt diff --git a/test/tests/inc/fromline.txt b/test/inc/fromline.txt similarity index 100% rename from test/tests/inc/fromline.txt rename to test/inc/fromline.txt diff --git a/test/tests/inc/md5sums b/test/inc/md5sums similarity index 100% rename from test/tests/inc/md5sums rename to test/inc/md5sums diff --git a/test/tests/inc/msgheader.txt b/test/inc/msgheader.txt similarity index 100% rename from test/tests/inc/msgheader.txt rename to test/inc/msgheader.txt diff --git a/test/tests/inc/test-deb359167 b/test/inc/test-deb359167 old mode 100644 new mode 100755 similarity index 85% rename from test/tests/inc/test-deb359167 rename to test/inc/test-deb359167 index ef0abc8..26aea11 --- a/test/tests/inc/test-deb359167 +++ b/test/inc/test-deb359167 @@ -2,9 +2,11 @@ # 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 diff --git a/test/tests/inc/test-eom-align b/test/inc/test-eom-align old mode 100644 new mode 100755 similarity index 98% rename from test/tests/inc/test-eom-align rename to test/inc/test-eom-align index 2c1c67e..c0cae7c --- a/test/tests/inc/test-eom-align +++ b/test/inc/test-eom-align @@ -4,9 +4,11 @@ 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 diff --git a/test/tests/manpages/test-manpages b/test/manpages/test-manpages old mode 100644 new mode 100755 similarity index 91% rename from test/tests/manpages/test-manpages rename to test/manpages/test-manpages index f7acc69..7c221ba --- a/test/tests/manpages/test-manpages +++ b/test/manpages/test-manpages @@ -6,11 +6,13 @@ # ###################################################### -. $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 diff --git a/test/tests/mhbuild/test-forw b/test/mhbuild/test-forw old mode 100644 new mode 100755 similarity index 94% rename from test/tests/mhbuild/test-forw rename to test/mhbuild/test-forw index 1dece26..c92242f --- a/test/tests/mhbuild/test-forw +++ b/test/mhbuild/test-forw @@ -5,6 +5,14 @@ # ###################################################### +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() { diff --git a/test/tests/mhshow/test-cte-binary b/test/mhshow/test-cte-binary old mode 100644 new mode 100755 similarity index 87% rename from test/tests/mhshow/test-cte-binary rename to test/mhshow/test-cte-binary index 26b0f08..e5654bb --- a/test/tests/mhshow/test-cte-binary +++ b/test/mhshow/test-cte-binary @@ -5,6 +5,13 @@ # ###################################################### +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 diff --git a/test/tests/mhshow/test-qp b/test/mhshow/test-qp old mode 100644 new mode 100755 similarity index 89% rename from test/tests/mhshow/test-qp rename to test/mhshow/test-qp index ae6ec05..c19a343 --- a/test/tests/mhshow/test-qp +++ b/test/mhshow/test-qp @@ -7,6 +7,14 @@ 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 diff --git a/test/tests/mhshow/test-subpart b/test/mhshow/test-subpart old mode 100644 new mode 100755 similarity index 89% rename from test/tests/mhshow/test-subpart rename to test/mhshow/test-subpart index 269c9f4..9d8fe29 --- a/test/tests/mhshow/test-subpart +++ b/test/mhshow/test-subpart @@ -8,6 +8,14 @@ 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 diff --git a/test/tests/new/test-basic b/test/new/test-basic old mode 100644 new mode 100755 similarity index 96% rename from test/tests/new/test-basic rename to test/new/test-basic index 772b72f..3b2befd --- a/test/tests/new/test-basic +++ b/test/new/test-basic @@ -1,5 +1,12 @@ #!/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() { diff --git a/test/tests/pick/test-stderr b/test/pick/test-stderr old mode 100644 new mode 100755 similarity index 71% rename from test/tests/pick/test-stderr rename to test/pick/test-stderr index 35a64ef..f3212da --- a/test/tests/pick/test-stderr +++ b/test/pick/test-stderr @@ -5,6 +5,14 @@ # ###################################################### +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 @@ -20,5 +28,5 @@ EOF 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 diff --git a/test/tests/repl/test-if-str b/test/repl/test-if-str old mode 100644 new mode 100755 similarity index 85% rename from test/tests/repl/test-if-str rename to test/repl/test-if-str index 7582a7d..6bc0e09 --- a/test/tests/repl/test-if-str +++ b/test/repl/test-if-str @@ -8,6 +8,14 @@ # ###################################################### +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 < 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 diff --git a/test/runalltests b/test/runalltests deleted file mode 100755 index 48ba7f1..0000000 --- a/test/runalltests +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 diff --git a/test/runtest b/test/runtest deleted file mode 100755 index f23608b..0000000 --- a/test/runtest +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -status=1 - -[ $# -eq 1 ] || echo "usage: $0 "'' - -# 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 < -To: Some User -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 diff --git a/test/tests/scan/test-scan b/test/scan/test-scan old mode 100644 new mode 100755 similarity index 85% rename from test/tests/scan/test-scan rename to test/scan/test-scan index 780a69d..1b688e0 --- a/test/tests/scan/test-scan +++ b/test/scan/test-scan @@ -5,6 +5,14 @@ # ###################################################### +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 @@ -21,6 +29,6 @@ cat > $expected <> EOF -scan -width 80 +inbox > $actual +scan -width 80 +inbox > $actual || exit 1 diff -u $expected $actual diff --git a/test/setup-test b/test/setup-test deleted file mode 100755 index bf405f3..0000000 --- a/test/setup-test +++ /dev/null @@ -1,46 +0,0 @@ -#!/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 diff --git a/test/teardown-test b/test/teardown-test deleted file mode 100755 index 5dec4ab..0000000 --- a/test/teardown-test +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# Get full pathnames that we'll need. -testdir=`dirname $0` -builddir=$testdir/testbuild -testinstalldir=$testdir/testinstall - -rm -rf $builddir $testinstalldir diff --git a/test/tests/whatnow/test-attach-detach b/test/whatnow/test-attach-detach old mode 100644 new mode 100755 similarity index 86% rename from test/tests/whatnow/test-attach-detach rename to test/whatnow/test-attach-detach index 1a36d8d..4314553 --- a/test/tests/whatnow/test-attach-detach +++ b/test/whatnow/test-attach-detach @@ -6,6 +6,14 @@ # ###################################################### +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" @@ -34,5 +42,5 @@ echo "detach baz\\'s\\ boz" | whatnow -attach foo -noedit -prompt '' 2>> $actual 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 diff --git a/test/tests/whatnow/test-cd b/test/whatnow/test-cd old mode 100644 new mode 100755 similarity index 81% rename from test/tests/whatnow/test-cd rename to test/whatnow/test-cd index 3e0ddc4..d92f334 --- a/test/tests/whatnow/test-cd +++ b/test/whatnow/test-cd @@ -6,6 +6,14 @@ # ###################################################### +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" @@ -30,5 +38,5 @@ EOF # 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 diff --git a/test/tests/whatnow/test-ls b/test/whatnow/test-ls old mode 100644 new mode 100755 similarity index 79% rename from test/tests/whatnow/test-ls rename to test/whatnow/test-ls index e0dc969..58ee2f6 --- a/test/tests/whatnow/test-ls +++ b/test/whatnow/test-ls @@ -6,6 +6,14 @@ # ###################################################### +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" @@ -29,5 +37,5 @@ EOF # 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 -- 1.7.10.4