1#! /bin/sh
2
3set -e
4
5# Note:  When run via "make check", test output files are automatically deleted.
6#	 When run from the command line, outputs files are left in directory
7#	 lexer.mbx.YYYYMMDD.  This is useful when something is different.
8#
9#	 ./inputs  - test inputs
10#	 ./outputs - known correct outputs
11#
12#	 lexer.mbx.YYYYMMDD:
13#		tests   - directory containing individual output files
14
15: ${srcdir=.}
16relpath="`pwd`/../.."
17
18NODB=1 . ${srcdir}/../t.frame
19
20OUT="lexer.mbx.out"
21
22verbose=0
23if [ "$1" = "-v" ]; then
24    verbose=1
25    v="-v"
26fi
27
28if [ "$1" = "-vv" ]; then
29    verbose=1
30    v="-v -x l"
31fi
32
33BOGOLEXER="$VAL ${relpath}/bogolexer"
34for f in good spam ; do
35    $BOGOLEXER -C -D -p $v < ${srcdir}/inputs/$f.mbx > $TMPDIR/$f.1
36    sort < $TMPDIR/$f.1 | uniq > $TMPDIR/$f.2
37    if  [ $verbose -ne 0 ]; then
38	$BOGOLEXER -C -D -x ml -vvv -p < ${srcdir}/inputs/$f.mbx > $TMPDIR/$f.v
39    fi
40done
41
42RESULT=`cat $TMPDIR/spam.2 | wc -l`.`cat $TMPDIR/good.2 | wc -l`
43RESULT=`echo $RESULT | sed s@\ @@g`
44
45#strict checking
46WANT="1102.3073"
47#loose checking
48WANT="1103.3073"
49# v0.12.4 - parsing adds '!' and money amounts
50WANT="1126.3080"
51# v0.13.0 - new parsing rules - case sensitive, header_line_markup, tokenize_html_tags
52WANT="1690.3918"
53# v0.13.5 - new parsing rules - allow terminal exclamation points
54WANT="1724.3937"
55# v0.13.6.2 - lexer_v3.l changes to exclude brackets
56WANT="1723.3931"
57# v0.13.7.3 - lexer_v3.l changes to allow space in mime boundary
58WANT="1722.3929"
59# v0.15 - removed html.c - process_html_comments()
60WANT="1720.3925"
61# v0.15.1 - unfolding header lines ...
62WANT="1720.3927"
63# v0.15.1 - discarding message separators
64WANT="1710.3914"
65# v0.15.1 - discarding additional message ids
66WANT="1708.3909"
67
68if [ "$RESULT" != "$WANT" -o $verbose -ne 0 ] ; then
69    echo want: $WANT, have: $RESULT | tee $TMPDIR/$OUT
70fi
71
72[ ! -z "$BF_SAVEDIR" ] && . ${srcdir}/../t.save
73
74test "$RESULT" = "$WANT"
75