Reworked test suite to copy the configuration used in the main
[mmh] / test / setup-test
index d197295..bf405f3 100755 (executable)
@@ -1,30 +1,46 @@
 #!/bin/sh
+#
+# Copy our sources and configuration, but change the installation
+# prefix so that we can test with a completely independent
+# installation.
 
-TEMPDIR=`mktemp -d /tmp/nmh-test-XXXXXXXX`
-echo $TEMPDIR > test-temp-dir
+# 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
 
-pushd ..
-aclocal
-autoheader
-autoconf
-./configure --prefix=$TEMPDIR --with-locking=fcntl
-make install
+#### Set up builddir.
+[ -d $builddir ]  ||  mkdir -p $builddir
+cd $builddir
 
-echo "Path: $TEMPDIR/Mail" > $TEMPDIR/mh_profile
-mkdir $TEMPDIR/Mail
+#### 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
 
-MH=$TEMPDIR/mh_profile $TEMPDIR/bin/folder -create +inbox
+#### 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
 
-for i in `seq 1 10`;
-do
-    cat > $TEMPDIR/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
+echo configuring the test installation in "$installdir" . . .
+/bin/sh $reconfig > /dev/null
 
-This is message number $i
-EOF
-done
-
-popd
+echo building the test installation . . .
+make install > /dev/null