]> git.marmaro.de Git - mmh/commitdiff
Rearranged test suite environment variables so that individual tests
authorDavid Levine <levinedl@acm.org>
Fri, 17 Feb 2012 03:30:43 +0000 (21:30 -0600)
committerDavid Levine <levinedl@acm.org>
Fri, 17 Feb 2012 03:30:43 +0000 (21:30 -0600)
can now be run standalone (outside of make).  But see WARNING in
test/README about how it's better to use "make check" because that
ensures that the current code in your workspace is tested.  Also, the
clean script no longer needs to call setup_test.

25 files changed:
Makefile.am
test/README
test/bad-input/test-header
test/cleanup
test/common.sh.in
test/folder/test-create
test/folder/test-total
test/format/test-localmbox
test/format/test-myhost
test/format/test-mymbox
test/format/test-myname
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

index 5b473c38fbf5af4d873000c11f47dffc489492c3..2a986b05c53f3d5ebc3226b7e4aa7729fb7f6279 100644 (file)
@@ -34,10 +34,10 @@ auxexecdir = @libdir@
 ## 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
 ##
index 3d7d478b4b77948209e6484e1a87d2230d6565df..9f890e2dcb2ee4646068f80cc20f38541167e9b3 100644 (file)
@@ -17,18 +17,27 @@ 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".
 
-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".
index 35d680a63c821e33f52e45fe43c71f961bd6706b..71a63a9abbc4eda8f4d064d0f5fc3c2d7986c5ea 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index 82b22616a18bf39dde6753c1e12b14d0daae40ca..97d83411d6def9ec8eb02b1323e764449d9b95be 100755 (executable)
@@ -5,12 +5,11 @@
 # 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}
index d5a9d7e143e34fad41937f21097055620de174ca..7596a4850d7b40ce5563e4704e234f83a1dc4360 100644 (file)
@@ -1,6 +1,24 @@
 # 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@
@@ -61,20 +79,13 @@ progress_done ()
 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
index a3460ee98fdc653d43cae8c0e2bdcff95269601f..2e9e62742d677346b721e648693023df253c6828 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index 86b304f3bb4670bca279f8de77592ad506d5701c..c222792839055ed94ef0c391c7320ec17f11e341 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index 196b03b808c6988d9a45eba29ccb49e40e455735..8ee6884a2885704018c612373acd24cafa83efba 100755 (executable)
@@ -4,11 +4,12 @@
 # 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
 
index d303a8f2f47604026df9bd72f587369e19522d62..c132565291abebafb147003179a3fce5d48ff84b 100755 (executable)
@@ -4,11 +4,12 @@
 # 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
 
index 82f08792c94883384ac94a8d5a20e2558a08a9c4..5a8ef419bdb7c792fc610867bc4e64703fb5b907 100755 (executable)
@@ -4,11 +4,12 @@
 # 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
 
index 4e1dfaa35b540c5495dacdb11c7c618cd2a9e000..97a053986036fd95a8f1aacc3e80663142033768 100755 (executable)
@@ -4,11 +4,12 @@
 # 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
 
index 72c6b7f91e9f159d1414411556c1e44e98264a38..d2b2302990709831a30c46981e4952a5e69a4c73 100755 (executable)
@@ -2,11 +2,16 @@
 # 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
 
index 276d70c7208f2a16b2cd1afb72f2d08921a1b202..06c972bd11f6fd5193abb692ba44d7f41a8c93af 100755 (executable)
@@ -4,11 +4,16 @@
 
 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
index 7c221bae31c19c8b5c4efa358f7aae19264a2c5b..7cb7db81bec0fa50598e70f22f111551321756f0 100755 (executable)
@@ -6,7 +6,12 @@
 #
 ######################################################
 
-. ${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
 
index c92242f79e456105c05805b381ee216e8029ad33..e9a1b2f5c10836fc4b036652f19f4b861f3fdc33 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index e5654bbff52f623ca7e024a8edc1199b56b9a312..7d2125d78ba852f6a12a9ec26677ad02a8c89c23 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
index c19a34353c0ae003930512c4b61bc75e92605310..8116b2137f427c1445d6c55b50028b5430fcd014 100755 (executable)
@@ -7,11 +7,12 @@
 
 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
 
index 9d8fe2980afd752705e190b96872e0d64a8fb20b..353962dc41e33b6021029025aeaea9910b445544 100755 (executable)
@@ -8,11 +8,12 @@
 
 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
 
index 3b2befdbcafb9cb71e19c84a84c17e931f76f9a0..ca1a4cf25ebf6e9027548214dc61de1e8b01cd0f 100755 (executable)
@@ -1,10 +1,16 @@
 #!/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...
index f3212da114ab1e8dcf2aee48946251bd0760de74..07a2cf2701b037e8d1324cd8a39548d6905ce1b1 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index 6bc0e097fb3d304161f8b88d7ef6786f4c6dde30..2ed4fd0b524262be023e1bd22da54373aae5f112 100755 (executable)
@@ -8,11 +8,12 @@
 #
 ######################################################
 
-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
 
index 1b688e03bd51461878c16c2864b087edf2899580..8e59b96ebbf61d08326e0871747c78a89d7ec4a4 100755 (executable)
@@ -5,11 +5,12 @@
 #
 ######################################################
 
-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
 
index 43145538c3a9ca80619c21601800ffad7b9fc483..5c359decfe9ccdfe54af5217a7029a839ec83f44 100755 (executable)
@@ -6,11 +6,12 @@
 #
 ######################################################
 
-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
 
index d92f334fca0b6167171ccb31426a13623d676c80..d39d9cfc35bbc9e9d55f1e15579c176c0bb75730 100755 (executable)
@@ -6,11 +6,12 @@
 #
 ######################################################
 
-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
 
index 58ee2f61fba0b18abed88d3db9a32f8678084250..050403675481137e7e2c3f00f284a859d8a3410d 100755 (executable)
@@ -6,11 +6,12 @@
 #
 ######################################################
 
-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