minix/external/bsd/byacc/dist/test/run_test.sh

83 lines
1.4 KiB
Bash
Raw Normal View History

2012-06-06 15:25:48 +02:00
#!/bin/sh
# Id: run_test.sh,v 1.8 2012/01/15 11:50:35 tom Exp
2012-06-06 15:25:48 +02:00
# vi:ts=4 sw=4:
if test $# = 1
then
PROG_DIR=`pwd`
TEST_DIR=$1
else
PROG_DIR=..
TEST_DIR=.
fi
YACC=$PROG_DIR/yacc
tmpfile=temp$$
rm -f test-*
2012-06-06 15:25:48 +02:00
echo '** '`date`
for input in ${TEST_DIR}/*.y
2012-06-06 15:25:48 +02:00
do
case $input in
2012-06-06 15:25:48 +02:00
test*)
echo "?? ignored $input"
2012-06-06 15:25:48 +02:00
;;
*)
root=`basename $input .y`
2012-06-06 15:25:48 +02:00
ROOT="test-$root"
prefix=${root}_
OPTS=
OPT2=
2012-06-06 15:25:48 +02:00
TYPE=".output .tab.c .tab.h"
case $input in
2012-06-06 15:25:48 +02:00
${TEST_DIR}/code_*)
OPTS="$OPTS -r"
TYPE="$TYPE .code.c"
prefix=`echo "$prefix" | sed -e 's/^code_//'`
;;
${TEST_DIR}/pure_*)
OPTS="$OPTS -P"
prefix=`echo "$prefix" | sed -e 's/^pure_//'`
;;
${TEST_DIR}/quote_*)
OPT2="-s"
;;
2012-06-06 15:25:48 +02:00
esac
for opt2 in "" $OPT2
2012-06-06 15:25:48 +02:00
do
$YACC $OPTS $opt2 -v -d -p $prefix -b $ROOT${opt2} $input
for type in $TYPE
do
REF=${TEST_DIR}/${root}${opt2}${type}
CMP=${ROOT}${opt2}${type}
if test ! -f $CMP
then
echo "...not found $CMP"
else
sed -e s,$CMP,$REF, \
-e /YYPATCH/d \
-e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
< $CMP >$tmpfile \
&& mv $tmpfile $CMP
if test ! -f $REF
then
mv $CMP $REF
echo "...saved $REF"
elif ( cmp -s $REF $CMP )
then
echo "...ok $REF"
rm -f $CMP
else
echo "...diff $REF"
diff -u $REF $CMP
fi
fi
done
2012-06-06 15:25:48 +02:00
done
;;
esac
done