3 TEMP=`getopt -o c:d:m: -- "$@"`
5 matitac="`pwd`/matitac.opt"
7 matitadep="./matitadep.opt"
11 -d) libdir="$2"; shift 2 ;;
12 -c) matitac="$2"; shift 2 ;;
13 -m) devel="$2"; shift 2 ;;
15 *) echo "Usage: errors_bench [-c MATITAC_PATH] [-d LIBRARY_DIR] [-m MATITAMAKE_DEVEL]"; exit 1 ;;
18 if ! [ -d "$libdir" ] ; then
19 echo "Can't find library directory '$libdir'"
22 if ! [ -x "$matitac" ] ; then
23 echo "Can't find executable Matita compiler '$matitac'"
27 ma_s=$(find $libdir -name "*.ma" -type f)
28 sorted_ma_s=$($matitadep -order $ma_s)
30 log="bench_disamberrors.txt"
32 echo -e "# FILENAME\tOUTCOME\tEXPECTED_ERROR\tERRORS\tSPURIOUS_ERRORS" > $log
33 # format: tab-separated fields:
34 # FILENAME OUTCOME EXPECTED_ERROR ERRORS SPURIOUS_ERRORS
36 # OUTCOME is one of {"OK","KO","UNKNOWN(n)"}, n is an exit code
37 # EXPECTED_ERROR is FROM-TO, where FROM and TO are character counts
38 # ERRORS, same format as above (FROM-TO)
39 # SPURIOUS_ERRORS, same format as above (FROM-TO)
42 echo -e "$1|$2|$3|$4|$5" >> "$log"
45 for ma in $sorted_ma_s ; do
46 mo=`echo $ma | sed 's/\.ma$/.mo/'`
47 make -C $libdir $mo # ensure deps for $mo have been built
48 rotten_mas=$(ls $libdir/$ma.*.rottened)
49 for rotten_ma in $rotten_mas ; do
50 rotten_ma=$(echo $rotten_ma | sed s@^$(pwd)/@@) # prettier names
52 tmp="bench_disamberrors.tmp"
53 $matitac $rotten_ma &> $tmp
55 if [ "$outcome" = 3 ] ; then
57 elif [ "$outcome" = 0 ] ; then
60 outcome="UNKNOWN($outcome)"
62 supposed_error=$(grep ^error-at: $rotten_ma | cut -f 2 -d' ')
68 if echo "$e" | grep -q "Error at" && [ -n "$error_pass" ] ; then
69 # this is an error location line
70 if echo "$e" | grep -q "Spurious" ; then
71 loc=$(echo "$e" | sed 's/:.*$//' | cut -f 4 -d ' ')
72 if ! echo "$spurious_errors" | grep -q "$loc"; then
73 if ! [ -z "$spurious_errors" ] ; then spurious_errors="$spurious_errors," ; fi
74 spurious_errors="$spurious_errors$loc"
77 loc=$(echo "$e" | sed 's/:.*$//' | cut -f 3 -d ' ')
78 if ! echo "$errors" | grep -q "$loc"; then
79 if ! [ -z "$errors" ] ; then errors="$errors," ; fi
84 error_pass=$(echo "$e" | grep "during phases " | sed 's/:.*$//' | cut -f 6 -d' ' | grep "4\|6")
86 log_outcome $rotten_ma $outcome $supposed_error $errors $spurious_errors
90 echo "See $log for benchmark results"