2 TEMP=`getopt -o c:d:m: -- "$@"`
4 matitac="`pwd`/matitac.opt"
6 matitadep="./matitadep.opt"
10 -d) libdir="$2"; shift 2 ;;
11 -c) matitac="$2"; shift 2 ;;
13 *) echo "Usage: errors_bench [-c MATITAC_PATH] [-d LIBRARY_DIR] [-m MATITAMAKE_DEVEL]"; exit 1 ;;
16 if ! [ -d "$libdir" ] ; then
17 echo "Can't find library directory '$libdir'"
20 if ! [ -x "$matitac" ] ; then
21 echo "Can't find executable Matita compiler '$matitac'"
25 ma_s=$(find $libdir -name "*.ma" -type f)
26 sorted_ma_s=$($matitadep -order $ma_s)
28 log="bench_disamberrors.txt"
30 echo -e "# FILENAME\tOUTCOME\tEXPECTED_ERROR\tERRORS\tSPURIOUS_ERRORS" > $log
31 # format: tab-separated fields:
32 # FILENAME OUTCOME EXPECTED_ERROR ERRORS SPURIOUS_ERRORS
34 # OUTCOME is one of {"OK","KO","UNKNOWN(n)"}, n is an exit code
35 # EXPECTED_ERROR is FROM-TO, where FROM and TO are character counts
36 # ERRORS, same format as above (FROM-TO)
37 # SPURIOUS_ERRORS, same format as above (FROM-TO)
40 echo -e "$1\t$2\t$3\t$4\t$5" >> "$log"
43 for ma in $sorted_ma_s ; do
44 mo=`echo $ma | sed 's/\.ma$/.mo/'`
45 make -C $libdir $mo # ensure deps for $mo have been built
46 rotten_mas=$(ls $libdir/$ma.*.rottened)
47 for rotten_ma in $rotten_mas ; do
48 rotten_ma=$(echo $rotten_ma | sed s@^$(pwd)/@@) # prettier names
50 tmp="bench_disamberrors.tmp"
51 $matitac $rotten_ma &> $tmp
53 if [ "$outcome" = 3 ] ; then
55 elif [ "$outcome" = 0 ] ; then
58 outcome="UNKNOWN($outcome)"
60 supposed_error=$(grep ^error-at: $rotten_ma | cut -f 2 -d' ')
61 raw_errors=$(grep '^*Error at' $tmp | sed 's/:.*$//' | cut -f 3 -d' ')
63 for e in $raw_errors ; do
64 if ! [ -z "$errors" ] ; then errors="$errors," ; fi
67 raw_spurious_errors=$(grep '^*(Spurious?) Error at' $tmp | sed 's/:.*$//' | cut -f 4 -d' ')
69 for e in $raw_spurious_errors ; do
70 if ! [ -z "$spurious_errors" ] ; then spurious_errors="$spurious_errors," ; fi
71 spurious_errors="$spurious_errors$e"
73 log_outcome $rotten_ma $outcome $supposed_error $errors $spurious_errors
77 echo "See $log for benchmark results"