#!/usr/bin/env bash set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR 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+=" \n" } function yellow { (( fail += 1 )) printf "$1: ${YELLOW}$2${NC}\n" XML+=" \n $2\n \n" } function red { (( fail += 1 )) printf "$1: ${RED}$2${NC}\n" XML+=" \n $2\n \n" } function finish_suite { printf "$1: Passed ${pass} out of $(( pass + fail ))\n" XML=" \n$XML \n" printf "$XML" >> $DIR/tests.xml XML="" pass=0 fail=0 } SAILLIBDIR="$DIR/../../lib/" printf "\n" >> $DIR/tests.xml for i in `ls -d */`; do cd $DIR/$i; if $SAILDIR/sail -new_parser -o out -ocaml ../prelude.sail `ls *.sail` 1> /dev/null; 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 finish_suite "Ocaml testing" cd $DIR for i in `ls -d */`; do cd $DIR/$i; if $SAILDIR/sail -new_parser -o out -ocaml_trace ../prelude.sail `ls *.sail` 1> /dev/null; then ./out > result 2> /dev/null; 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 finish_suite "Ocaml trace testing" printf "\n" >> $DIR/tests.xml