X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2Fscripts%2Fdo_tests.sh;h=e8e4ddda4e9cc19e1b9dbcc8418f0a22e5b989c8;hb=1276d3c7b85f4edc049a5d68a6120816fe64c806;hp=5e8b0d583bda5f1cd31f768fc61f609089fc38e7;hpb=a7667815758ad8e3cf2a9921c0ccfb9bcb29bb54;p=helm.git diff --git a/helm/matita/scripts/do_tests.sh b/helm/matita/scripts/do_tests.sh index 5e8b0d583..e8e4ddda4 100755 --- a/helm/matita/scripts/do_tests.sh +++ b/helm/matita/scripts/do_tests.sh @@ -19,23 +19,29 @@ CLEANER=$1 shift LOGFILE=$1 shift +EXPECTED=$1 +shift TODO="$@" -if [ -z "$COMPILER" -o -z "$CLEANER" -o -z "$LOGFILE" -o -z "$TODO" ]; then +if [ -z "$COMPILER" -o -z "$CLEANER" -o -z "$LOGFILE" -o -z "$EXPECTED" -o -z "$TODO" ]; then echo echo "usage: " - echo " do_tests.sh [-no-color] [-twice] ./compiler ./cleaner logfile tests.ma ..." + echo " do_tests.sh [-no-color] [-twice] ./compiler ./cleaner logfile expected_result test.ma ..." echo echo "options: " echo " -no-color Do not use vt100 colors" echo " -twice Run each test twice but show only the second run times" echo + echo "If expected_result is OK the result will be OK if the test compiles." + echo "Otherwise if expected_result is FAIL the result will be OK if the test" + echo "does not compile and the generated output is equal to test.log." echo "The value of the DO_TESTS_EXTRA evironment variable" echo "will be appended to each line." exit 1 fi -TMP=.__temp.txt +LOG=.__log +DIFF=.__diff export TIMEFORMAT="%2lR %2lU %2lS" for T in $TODO; do @@ -45,12 +51,26 @@ for T in $TODO; do $COMPILER $T 1>/dev/null 2>/dev/null fi $CLEANER $T 1>/dev/null 2>/dev/null - TIMES=`(time $COMPILER $T >> $LOGFILE 2>&1) 2>&1` + TIMES=`(time $COMPILER $T > $LOG 2>&1) 2>&1` RC=$?; + cat $LOG >> $LOGFILE + touch $DIFF + if [ $EXPECTED = "FAIL" ]; then + if [ $RC = 0 ]; then + echo "The test was successful but it should have failed!" > $DIFF + RC=1; + else + diff $LOG `basename $T .ma`.log > $DIFF + RC=$? + rm -f $LOG + fi + fi if [ $RC = 0 ]; then printf "$OK\t$TIMES\t$DO_TESTS_EXTRA\n" else printf "$FAIL\t$TIMES\t$DO_TESTS_EXTRA\n"; - exit $RC + cat $DIFF fi + rm -f $DIFF + exit $RC done