From 187dcd089f8a86e8d8e769769496f791d69ec09d Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 28 Sep 2014 21:46:13 +0200 Subject: Added the first tests --- run_tests.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 run_tests.sh (limited to 'run_tests.sh') diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..dcfa7ef --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,34 @@ +#!/bin/env bash + +tmp=$(mktemp -d "/tmp/tamasheq.XXXX") +failure_count=0 + +cd tests + +for input in *.ml; do + expected="${input/ml/expected}" + name="${input%\.ml}" + output="$tmp/${input/ml/output}" + + if ../tamasheq -denv -o "$tmp" "$input" > "$output" 2>&1; then + if cmp -s "$expected" "$output"; then + printf "%-20s\tSUCCESS\n" "$name" >&2 + rm "$tmp"/* + else + printf "%-20s\tFAILURE\n" "$name" >&2 + failure_count=$((failure_count + 1)) + fi + else + printf "%-20s\tFAILURE\n" "$name" >&2 + failure_count=$((failure_count + 1)) + fi +done + +if [ "$failure_count" -gt 0 ]; then + printf "\n$failure_count test(s) failed\nplease see $tmp for more information\n" >&2 + exit 1 +else + printf "\nall the tests were successful\n" >&2 + rm -r "$tmp" + exit 0 +fi -- cgit v1.2.3-70-g09d2