#!/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
#	 parsing.YYYYMMDD.  This is useful when something is different.
#
#	 ./inputs  - test inputs
#	 ./outputs - known correct outputs
#		     esp. parsing.out
#
#	 parsing.YYYYMMDD:
#		directory containing individual output files

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

map_rc()
{
    (
	set +e
	eval "$@"
	a=$?
	[ $a -eq 0 ] && exit 0
	[ $a -eq 1 ] && exit 0
	exit $a
    )
}

MSG="$SYSTEST/inputs/msg.parsing.txt"
flaglist="IhT-2"

for flags in $flaglist ; do
    opts=`echo $flags | tr -d "01234567-"`
    ( echo "****** " $opts " ******" ; \
    $BOGOLEXER -C -D -p -v < "$MSG" ) | tee -a "$TMPDIR/parsing.out" > "$TMPDIR/tmp"
    if  [ $verbose -ne 0 ]; then
	sort -u < "$TMPDIR"/tmp >> "$TMPDIR/parsing.sor"
    fi
done

if  [ $verbose -ne 0 ]; then
    wc -l "$TMPDIR/parsing.out"
    wc -l "$TMPDIR"/parsing.sor
fi

OUT="${OUTPUTS}/parsing.out"

test  $verbose -eq 0 && cmp "$OUT" "$TMPDIR/parsing.out" \
|| diff $DIFF_BRIEF "$OUT" "$TMPDIR"/parsing.out
