]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/scripts/do_tests.sh
more makefile work
[helm.git] / helm / matita / scripts / do_tests.sh
1 #!/bin/bash
2
3 OK="\e[32mOK\e[0m"
4 FAIL="\e[31mFAIL\e[0m"
5
6 if [ "$1" = "-no-color" ]; then
7   shift
8   OK="OK"
9   FAIL="FAIL"
10 fi
11 if [ "$1" = "-twice" ]; then
12   shift
13   TWICE=1
14 fi
15
16 COMPILER=$1
17 shift
18 CLEANER=$1
19 shift
20 LOGFILE=$1
21 shift
22 TODO="$@"
23
24 if [ -z "$COMPILER" -o -z "$CLEANER" -o -z "$LOGFILE" -o -z "$TODO" ]; then
25   echo
26   echo "usage: "
27   echo "  do_tests.sh [-no-color] [-twice] ./compiler ./cleaner logfile tests.ma ..."
28   echo
29   echo "options:  "
30   echo "  -no-color Do not use vt100 colors"
31   echo "  -twice    Run each test twice but show only the second run times"
32   echo
33   echo "The value of the DO_TESTS_EXTRA evironment variable"
34   echo "will be appended to each line."
35   exit 1
36 fi
37
38 TMP=.__temp.txt
39
40 for T in $TODO; do
41   printf "$COMPILER\t%-30s   " $T
42   if [ "$TWICE" = "1" ]; then
43     $CLEANER $T 1>/dev/null 2>/dev/null
44     $COMPILER $T 1>/dev/null 2>/dev/null
45   fi
46   $CLEANER $T 1>/dev/null 2>/dev/null
47   /usr/bin/time --quiet -o $TMP -f "%E  %U  %S" $COMPILER $T >> $LOGFILE 2>&1
48   if [ $? = 0 ]; then
49     printf "$OK\t`cat $TMP`\t$DO_TESTS_EXTRA\n"
50   else
51     printf "$FAIL\t`cat $TMP`\t$DO_TESTS_EXTRA\n"
52   fi
53 done
54
55 rm $TMP