diff options
Diffstat (limited to 'test')
| -rwxr-xr-x | test/aarch64_small/run_tests.sh | 37 | ||||
| -rwxr-xr-x | test/arm/run_tests.sh | 37 | ||||
| -rwxr-xr-x | test/cheri/run_tests.sh | 32 | ||||
| -rwxr-xr-x | test/coq/run_tests.sh | 33 | ||||
| -rwxr-xr-x | test/isabelle/run_tests.sh | 32 | ||||
| -rw-r--r-- | test/latex/candperm.commands.tex.exp | 60 | ||||
| -rw-r--r-- | test/latex/candperm.sail | 67 | ||||
| -rwxr-xr-x | test/latex/run_tests.sh | 57 | ||||
| -rwxr-xr-x | test/lem/run_tests.sh | 38 | ||||
| -rwxr-xr-x | test/mono/run_tests.sh | 38 | ||||
| -rwxr-xr-x | test/ocaml/run_tests.sh | 37 | ||||
| -rwxr-xr-x | test/run_tests.sh | 6 | ||||
| -rw-r--r-- | test/test_helpers.sh | 36 | ||||
| -rwxr-xr-x | test/typecheck/run_tests.sh | 38 |
14 files changed, 244 insertions, 304 deletions
diff --git a/test/aarch64_small/run_tests.sh b/test/aarch64_small/run_tests.sh index 416ad9f1..619ee8d2 100755 --- a/test/aarch64_small/run_tests.sh +++ b/test/aarch64_small/run_tests.sh @@ -5,43 +5,10 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR SAILDIR="$DIR/../.." -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> $DIR/tests.xml diff --git a/test/arm/run_tests.sh b/test/arm/run_tests.sh index 9d7af14f..83839417 100755 --- a/test/arm/run_tests.sh +++ b/test/arm/run_tests.sh @@ -5,43 +5,10 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR SAILDIR="$DIR/../.." -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" SAILLIBDIR="$DIR/../../lib/" diff --git a/test/cheri/run_tests.sh b/test/cheri/run_tests.sh index 337974d7..5fa0cdcd 100755 --- a/test/cheri/run_tests.sh +++ b/test/cheri/run_tests.sh @@ -12,36 +12,8 @@ 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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" SAILLIBDIR="$DIR/../../lib/" diff --git a/test/coq/run_tests.sh b/test/coq/run_tests.sh index 2d1a1318..24978c4f 100755 --- a/test/coq/run_tests.sh +++ b/test/coq/run_tests.sh @@ -22,37 +22,8 @@ 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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> $DIR/tests.xml diff --git a/test/isabelle/run_tests.sh b/test/isabelle/run_tests.sh index 7b3f7bc1..ebc3472c 100755 --- a/test/isabelle/run_tests.sh +++ b/test/isabelle/run_tests.sh @@ -13,36 +13,8 @@ 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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" SAILLIBDIR="$DIR/../../lib/" diff --git a/test/latex/candperm.commands.tex.exp b/test/latex/candperm.commands.tex.exp new file mode 100644 index 00000000..df253d71 --- /dev/null +++ b/test/latex/candperm.commands.tex.exp @@ -0,0 +1,60 @@ +\providecommand\saildoclabelled[2]{\phantomsection\label{#1}#2} + +\newcommand{\sailtypeast}{\saildoclabelled{typezast}{\saildoctype{}{\lstinputlisting[language=sail]{out/typezast6bb070d12e82e4887160cdfd016230c8.tex}}}} + +\newcommand{\sailvalexecute}{\saildoclabelled{zexecute}{\saildocval{}{\lstinputlisting[language=sail]{out/valzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermBrokenexecute}{\saildoclabelled{fclCAndPermBrokenzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref\hyperref[ztablezGpseudocodezDconstants]{\lstinline{table:pseudocode-constants}}{\emph{first\_uperm}} .. +\hyperref\hyperref[ztablezGpseudocodezDconstants]{\lstinline{table:pseudocode-constants}}{\emph{last\_uperm}} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermBrokenzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermEscapedexecute}{\saildoclabelled{fclCAndPermEscapedzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref[table:pseudocode-constants]{\emph{first\_uperm}} .. +\hyperref[table:pseudocode-constants]{\emph{last\_uperm}} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermEscapedzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermMarkdownexecute}{\saildoclabelled{fclCAndPermMarkdownzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref[table:pseudocode-constants]{*first_uperm*} .. +\hyperref[table:pseudocode-constants]{*last_uperm*} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermMarkdownzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermMarkdownWithRefMacroexecute}{\saildoclabelled{fclCAndPermMarkdownWithRefMacrozexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \firstUPerm{} .. \lastUPerm{} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermMarkdownWithRefMacrozexecute33a689e3a631b9b905b85461d3814943.tex}}}} + + + +\newcommand{\sailval}[1]{ + \ifstrequal{#1}{execute}{\sailvalexecute}{}} + +\newcommand{\sailrefval}[2]{ + \ifstrequal{#1}{execute}{\hyperref[zexecute]{#2}}{}} + +\newcommand{\sailfn}[1]{ + } + +\newcommand{\sailreffn}[2]{ + } + +\newcommand{\sailtype}[1]{ + \ifstrequal{#1}{ast}{\sailtypeast}{}} + +\newcommand{\sailreftype}[2]{ + \ifstrequal{#1}{ast}{\hyperref[typezast]{#2}}{}} diff --git a/test/latex/candperm.sail b/test/latex/candperm.sail new file mode 100644 index 00000000..75482db1 --- /dev/null +++ b/test/latex/candperm.sail @@ -0,0 +1,67 @@ +default Order dec + +scattered union ast('datasize : Int, 'destsize : Int, 'regsize : Int) +val execute : forall ('datasize : Int) ('destsize : Int) ('regsize : Int). + ast('datasize, 'destsize, 'regsize) -> unit + +/* Note: need at least two function clauses to generate latex output */ +scattered function execute +/* + * The naive copy-paste of the existing latex fails due to [] being interpreted as a link. + */ +union clause ast = CAndPermBroken : (int, int, int) +/*! + * Capability register \emph{cd} is replaced with the contents of capability + * register \emph{cs1} with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register \emph{rs2} + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \hyperref[table:pseudocode-constants]{\emph{first\_uperm}} .. + * \hyperref[table:pseudocode-constants]{\emph{last\_uperm}} of \emph{rd}. + */ +function clause execute(CAndPermBroken(cd, cs1, rs2)) = { + /* Implementation */ + return () +} +union clause ast = CAndPermEscaped : (int, int, int) +/*! + * Capability register \emph{cd} is replaced with the contents of capability + * register \emph{cs1} with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register \emph{rs2} + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \hyperref\[table:pseudocode-constants\]{\emph{first\_uperm}} .. + * \hyperref\[table:pseudocode-constants\]{\emph{last\_uperm}} of \emph{rd}. + */ +function clause execute(CAndPermEscaped(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +union clause ast = CAndPermMarkdown : (int, int, int) +/*! + * Capability register *cd* is replaced with the contents of capability + * register *cs1* with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register *rs2* + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits [*first_uperm*][<table:pseudocode-constants>] .. + * [*last_uperm*][<table:pseudocode-constants>] of *rd*. + */ +function clause execute(CAndPermMarkdown(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +union clause ast = CAndPermMarkdownWithRefMacro : (int, int, int) +/*! + * Capability register *cd* is replaced with the contents of capability + * register *cs1* with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register *rs2* + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \firstUPerm{} .. \lastUPerm{} of *rd*. + */ +function clause execute(CAndPermMarkdownWithRefMacro(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +end execute +end ast diff --git a/test/latex/run_tests.sh b/test/latex/run_tests.sh new file mode 100755 index 00000000..6ba3ce6f --- /dev/null +++ b/test/latex/run_tests.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$DIR" +SAILDIR="$DIR/../.." + +rm -f "$DIR/tests.xml" + +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" + + +printf "<testsuites>\n" >> "$DIR/tests.xml" + +find . -name '*.sail' -print0 | while IFS= read -r -d '' line; do + echo "$line" +done + +for testfile in *.sail; do + temp_dir=$(mktemp -d) + trap 'rm -rf $temp_dir' 0 2 3 15 + + if (cd "$temp_dir" && "$SAILDIR/sail" -o "out" -latex "$DIR/$testfile"); then + # compare with expected files + exp_prefix=${testfile//.sail/} + errmsg="Missing .exp files for $testfile?" + for expected in "${exp_prefix}"*.exp; do + echo "expected=$expected" + # remove prefix and suffix + exp_file_name=${expected//${exp_prefix}./} + generated_file="$temp_dir/out/${exp_file_name//.exp/}" + if [ ! -f "$generated_file" ]; then + errmsg="missing expected output $generated_file" + break; + elif ! diff -q "$generated_file" "$expected"; then + diff -u "$generated_file" "$expected" || true + errmsg="output is different" + break + else + errmsg="" + fi + done + if [ -z "$errmsg" ]; then + green "LaTeX for $testfile" "ok" + else + yellow "LaTeX for $testfile" "$errmsg" + fi; + else + red "failed to generate latex for $testfile" "fail" + fi + rm -rf "$temp_dir" +done + +finish_suite "LaTeX testing" + +printf "</testsuites>\n" >> "$DIR/tests.xml" diff --git a/test/lem/run_tests.sh b/test/lem/run_tests.sh index 7660b250..7d344ee0 100755 --- a/test/lem/run_tests.sh +++ b/test/lem/run_tests.sh @@ -5,44 +5,10 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SAILDIR="$DIR/../.." TESTSDIR="$DIR/../typecheck/pass" -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> $DIR/tests.xml diff --git a/test/mono/run_tests.sh b/test/mono/run_tests.sh index f95dc7d5..2bf41dff 100755 --- a/test/mono/run_tests.sh +++ b/test/mono/run_tests.sh @@ -6,44 +6,10 @@ SAILDIR=${SAIL_DIR:-"$DIR/../.."} TESTSDIR="$DIR" OUTPUTDIR="$DIR/test-output" -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> "$DIR/tests.xml" diff --git a/test/ocaml/run_tests.sh b/test/ocaml/run_tests.sh index f9328394..9dab7d75 100755 --- a/test/ocaml/run_tests.sh +++ b/test/ocaml/run_tests.sh @@ -5,43 +5,10 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR SAILDIR="$DIR/../.." -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> $DIR/tests.xml diff --git a/test/run_tests.sh b/test/run_tests.sh index 1af340d8..aafdad18 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -30,6 +30,12 @@ printf "==========================================\n" ./ocaml/run_tests.sh printf "\n==========================================\n" +printf "LaTeX tests\n" +printf "==========================================\n" + +./latex/run_tests.sh + +printf "\n==========================================\n" printf "C tests\n" printf "==========================================\n" diff --git a/test/test_helpers.sh b/test/test_helpers.sh new file mode 100644 index 00000000..40d66f10 --- /dev/null +++ b/test/test_helpers.sh @@ -0,0 +1,36 @@ +RED='\033[0;91m' +GREEN='\033[0;92m' +YELLOW='\033[0;93m' +NC='\033[0m' + +pass=0 +fail=0 +XML="" + +function green { + (( pass += 1 )) + printf "%s: ${GREEN}$2${NC}\n" "$1" + XML+=" <testcase name=\"$1\"/>\n" +} + +function yellow { + (( fail += 1 )) + printf "%s: ${YELLOW}$2${NC}\n" "$1" + XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n" +} + +function red { + (( fail += 1 )) + printf "%s: ${RED}$2${NC}\n" "$1" + XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n" +} + +function finish_suite { + printf "%s: Passed ${pass} out of $(( pass + fail ))\n\n" "$1" + XML=" <testsuite name=\"$1\" tests=\"$(( pass + fail ))\" failures=\"${fail}\" timestamp=\"$(date)\">\n$XML </testsuite>\n" + # Note: we use echo -e to escape \n characters + echo -e "$XML" >> "$DIR/tests.xml" + XML="" + pass=0 + fail=0 +} diff --git a/test/typecheck/run_tests.sh b/test/typecheck/run_tests.sh index e0720baf..bfc77899 100755 --- a/test/typecheck/run_tests.sh +++ b/test/typecheck/run_tests.sh @@ -4,47 +4,13 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SAILDIR="$DIR/../.." -RED='\033[0;91m' -GREEN='\033[0;92m' -YELLOW='\033[0;93m' -NC='\033[0m' - mkdir -p $DIR/rtpass mkdir -p $DIR/rtpass2 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\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 -} +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" printf "<testsuites>\n" >> $DIR/tests.xml |
