}
valgrind=""
+skeleton=""
wine=""
re2c="./re2c"
threads=`detect_cpu_count; echo $CPUS`
do
case $arg in
"--valgrind" ) valgrind=`which valgrind` ;;
+ "--skeleton" ) skeleton="--skeleton" ;;
"--wine" )
wine=`which wine`
re2c="${re2c}.exe"
local switches="$switches -W"
local cmd="${valgrind} ${wine} ${re2c} $switches $x"
- local outname_stdout="${outname}.stdout"
- local outname_stderr="${outname}.stderr"
- $cmd 2>$outname_stderr 1>$outname_stdout
- cat $outname_stderr $outname_stdout > $outname
- rm $outname_stderr $outname_stdout
- LC_ALL=C sed -i $outname \
- -e "s,$x,`basename $x`,g" \
- -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g'
- if test -n "$genname"
- then
- cat $genname | sed \
- -e 's,'"$test_srcdir"'/,,g' \
- -e 's,'"$test_blddir"'/,,g' \
- -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' \
- >> $outname
- rm $genname
- fi
- if test ! -f ${x%.re}.c
+ if [ x$skeleton == x"--skeleton" ]
then
- echo "FAIL missing ${x%.re}.c"
- local errcnt=$(($errcnt + 1))
- cp -f $x $outx
- else
- local r=`$diff_prog ${x%.re}.c $outname > $outdiff; echo $?`
- if [[ $r == 0 ]]
+ local outc="${outx%.re}.c"
+ cmd="${cmd} --skeleton -Werror-undefined-control-flow -o $outc"
+ mkdir -p `dirname "$outc"`
+
+ local status=""
+ [ -z $status ] && status=`$cmd 2>"$outc".stderr || echo "FAIL_RE2C"`
+ [ -z $status ] && status=`gcc -Wall -Wextra -o "$outc".out "$outc" 2>>"$outc".stderr || echo "FAIL_CC"`
+ [ -z $status ] && status=`./"$outc".out 2>>"$outc".stderr || echo "FAIL_RUN"`
+ [ -z $status ] && status="OK"
+ if [ $status = "OK" -o $status = "FAIL_RE2C" ]
then
- echo "OK $x: $switches"
- rm $outname
+ rm -f "$outc"{,.line*.{input,keys},.stderr,.out}
else
- echo "FAIL $x: $switches"
- local errcnt=$(($errcnt + 1))
cp -f $x $outx
- cp -f ${x%.re}.c ${outx%.re}.c
+ local errcnt=$(($errcnt + 1))
fi
- fi
- if test -n "$headers"
- then
- cat $headers | sed -e 's,'"$test_blddir"'/,,g' -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' > $typname
- rm $headers
- if test ! -f ${x%.re}.h
+ echo "$status $x"
+ else
+ local outname_stdout="${outname}.stdout"
+ local outname_stderr="${outname}.stderr"
+ $cmd 2>$outname_stderr 1>$outname_stdout
+ cat $outname_stderr $outname_stdout > $outname
+ rm $outname_stderr $outname_stdout
+ LC_ALL=C sed -i $outname \
+ -e "s,$x,`basename $x`,g" \
+ -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g'
+ if test -n "$genname"
then
- echo "FAIL missing ${x%.re}.h"
- local errcnt=$(($errcnt + 1))
- cp -f $x $outx
- elif $diff_prog ${x%.re}.h $typname > $typdiff
+ cat $genname | sed \
+ -e 's,'"$test_srcdir"'/,,g' \
+ -e 's,'"$test_blddir"'/,,g' \
+ -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' \
+ >> $outname
+ rm $genname
+ fi
+
+ if test ! -f ${x%.re}.c
then
- echo "OK $x: $switches"
- rm $typname
- else
- echo "FAIL $x: $switches"
+ echo "FAIL missing ${x%.re}.c"
local errcnt=$(($errcnt + 1))
cp -f $x $outx
- cp -f ${x%.re}.h ${outx%.re}.h
+ else
+ local r=`$diff_prog ${x%.re}.c $outname > $outdiff; echo $?`
+ if [[ $r == 0 ]]
+ then
+ echo "OK $x: $switches"
+ rm $outname
+ else
+ echo "FAIL $x: $switches"
+ local errcnt=$(($errcnt + 1))
+ cp -f $x $outx
+ cp -f ${x%.re}.c ${outx%.re}.c
+ fi
fi
+
+ if test -n "$headers"
+ then
+ cat $headers | sed -e 's,'"$test_blddir"'/,,g' -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' > $typname
+ rm $headers
+ if test ! -f ${x%.re}.h
+ then
+ echo "FAIL missing ${x%.re}.h"
+ local errcnt=$(($errcnt + 1))
+ cp -f $x $outx
+ elif $diff_prog ${x%.re}.h $typname > $typdiff
+ then
+ echo "OK $x: $switches"
+ rm $typname
+ else
+ echo "FAIL $x: $switches"
+ local errcnt=$(($errcnt + 1))
+ cp -f $x $outx
+ cp -f ${x%.re}.h ${outx%.re}.h
+ fi
+ fi
+ test -f $outdiff -a ! -s $outdiff && rm -f $outdiff
+ test -f $typdiff -a ! -s $typdiff && rm -f $typdiff
+
fi
- test -f $outdiff -a ! -s $outdiff && rm -f $outdiff
- test -f $typdiff -a ! -s $typdiff && rm -f $typdiff
done
echo $errcnt > $log
}