diff options
| author | Brian Campbell | 2017-09-04 12:09:59 +0100 |
|---|---|---|
| committer | Brian Campbell | 2017-09-04 12:09:59 +0100 |
| commit | 00cf8533221d2dfa650adcd38ac53943be5bd995 (patch) | |
| tree | 21a34e1f094ecec430798020e046dd3374e6e74c /test/ocaml/run_tests.sh | |
| parent | 461f3c914b2e767ef3ddb926712845d5442475f3 (diff) | |
| parent | de506ed9f9c290796f159f2b5279589519c2a198 (diff) | |
Merge branch 'experiments' of bitbucket.org:Peter_Sewell/sail into mono-experiments
Diffstat (limited to 'test/ocaml/run_tests.sh')
| -rwxr-xr-x | test/ocaml/run_tests.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/ocaml/run_tests.sh b/test/ocaml/run_tests.sh new file mode 100755 index 00000000..d01535b6 --- /dev/null +++ b/test/ocaml/run_tests.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SAILDIR="$DIR/../.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' + +rm -f $DIR/tests.xml + +pass=0 +fail=0 +XML="" + +function green { + (( pass += 1 )) + printf "$1: ${GREEN}$2${NC}\n" + XML+=" <testcase name=\"$1\"/>\n" +} + +function yellow { + (( fail += 1 )) + printf "$1: ${YELLOW}$2${NC}\n" + XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n" +} + +function red { + (( fail += 1 )) + printf "$1: ${RED}$2${NC}\n" + XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n" +} + +function finish_suite { + printf "$1: Passed ${pass} out of $(( pass + fail ))\n" + XML=" <testsuite name=\"$1\" tests=\"$(( pass + fail ))\" failures=\"${fail}\" timestamp=\"$(date)\">\n$XML </testsuite>\n" + printf "$XML" >> $DIR/tests.xml + XML="" + pass=0 + fail=0 +} + +SAILLIBDIR="$DIR" + +printf "<testsuites>\n" >> $DIR/tests.xml + +for i in `ls -d */`; +do + cd $DIR/$i; + if $SAILDIR/sail -o out -ocaml ../prelude.sail `ls *.sail`; + then + ./out > result; + if diff expect result; + then + green "built $i" "ok" + else + yellow "bad output $i" "fail" + fi; + rm out; + rm result; + rm -r _sbuild + else + red "building $i" "fail" + fi +done + +printf "</testsuites>\n" >> $DIR/tests.xml |
