summaryrefslogtreecommitdiff
path: root/test/coq/run_tests.sh
blob: 24978c4fc2f1f39204834b4cfaf8e6d58ba930ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SAILDIR="$DIR/../.."
TYPECHECKTESTSDIR="$DIR/../typecheck/pass"
EXTRATESTSDIR="$DIR/pass"

if opam config var coq-bbv:share >/dev/null 2>/dev/null; then
  COQOPTS="-Q $SAILDIR/lib/coq Sail"
else
  if [ -z "$BBVDIR" ]; then
    BBVDIR="$DIR/../../../bbv/src/bbv"
  fi
  COQOPTS="-Q $SAILDIR/lib/coq Sail -Q $BBVDIR bbv"
fi

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

rm -f $DIR/tests.xml

# shellcheck source=../test_helpers.sh
source "$SAILDIR/test/test_helpers.sh"

printf "<testsuites>\n" >> $DIR/tests.xml

cd $DIR

function check_tests_dir {
    TESTSDIR="$1"
    for i in `ls $TESTSDIR/ | grep sail | grep -vf "$DIR/skip"`;
    do
        if $SAILDIR/sail -coq -dcoq_undef_axioms -o out $TESTSDIR/$i &>/dev/null;
        then
    	if coqc $COQOPTS out_types.v &>/dev/null &&
    	   coqc $COQOPTS out.v &>/dev/null;
    	then
    	    green "tested $i expecting pass" "pass"
    	else
    	    yellow "tested $i expecting pass" "failed to typecheck generated Coq"
    	fi
        else
    	red "tested $i expecting pass" "failed to generate Coq"
        fi
    done
}

check_tests_dir "$TYPECHECKTESTSDIR"
check_tests_dir "$EXTRATESTSDIR"

finish_suite "Coq tests"

printf "</testsuites>\n" >> $DIR/tests.xml