#! /bin/sh

# Note:  When run via "make check", test output files are automatically deleted.
#	 When run from the command line, output files are left in directory
#	 wordhist.YYYYMMDD.  This is useful when something is different.
#
#	 ./inputs  - test inputs

NODB=1 . ${srcdir=.}/t.frame

[ -d "$TMPDIR"/tests ] && rm -rf "$TMPDIR"/tests
mkdir -p "$TMPDIR"/tests

OPTS="-C -y 0"

$BOGOFILTER $OPTS -s < "$SYSTEST/inputs/spam.mbx"
$BOGOFILTER $OPTS -n < "$SYSTEST/inputs/good.mbx"

(
set -e
$SHELL $BF_COMPACT $BOGOFILTER_DIR

$BOGOUTIL -d "$WORDLIST" >$BOGOFILTER_DIR/cpc
$BOGOUTIL -d "$BOGOFILTER_DIR/wordlist.$DB_EXT" >$BOGOFILTER_DIR/org

if [ $verbose -eq 0 ] ; then
    cmp $BOGOFILTER_DIR/org $BOGOFILTER_DIR/cpc
else
    diff $DIFF_BRIEF $BOGOFILTER_DIR/org $BOGOFILTER_DIR/cpc
fi
) && a=0 || a=$?
rm -rf "$BOGOFILTER_DIR.old"
exit $a
