#! /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
#	 maildir.YYYYMMDD.  This is useful when something is different.
#
#	 ./inputs/spam.mbx & ./inputs/good.mbx - test inputs
#	 ./outputs - known correct outputs
#
#	 maildir.YYYYMMDD:
#		directory containing individual output files

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

OUT="$TMPDIR"/maildir.out

CORRECT="$SYSTEST/outputs/maildir.out"

for f in good spam ; do
    mkdir "$TMPDIR"/$f
    mkdir "$TMPDIR"/$f/cur
    mkdir "$TMPDIR"/$f/tmp
    mkdir "$TMPDIR"/$f/new
    cat ${srcdir}/inputs/$f.mbx | ( cd "$TMPDIR"/$f/new && splitmbox )
done

$BOGOFILTER -C -D -n -B "$TMPDIR"/good
$BOGOFILTER -C -D -s -B "$TMPDIR"/spam
words=".MSG_COUNT Lotus Magazine Min Service connection more most set that unsubscribe"

$BOGOUTIL -w "$WORDLIST" $words > "$OUT" || rm -f "$OUT"

if  [ $verbose -eq 0 ]; then
    cmp "$CORRECT" "$OUT"
else
    diff $DIFF_BRIEF "$CORRECT" "$OUT"
fi
