From 21994864559386f1d11c001d6d27714cbf624a15 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 21 Jun 2024 12:56:30 +0100 Subject: add tests, and make dumping disasm optional --- run_tests.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 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..3c561a7 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +pass=0 +fail=0 + +for testfile in tests/*.bþ; do + outfile=${testfile%.bþ}.out + output="$(./bþ <$testfile 2>&1)" + run_res=$? + echo "$output" | diff $outfile - >/dev/null + diff_res=$? + testname=${testfile#tests/} + testname=${testname%.bþ} + case $diff_res in + 0) printf '\033[32m\033[1mPASS\033[0m %s\n' "$testname" + pass=$((pass + 1)) ;; + 1) printf '\033[31m\033[1mFAIL\033[0m %s\n' "$testname" + printf "\tgot output: %s\n" "$output" + printf "\texpected: " + cat $outfile + fail=$((fail + 1)) ;; + esac +done + +echo +printf "\033[32m%s\033[0m passed; " $pass +if [ $fail -eq 0 ]; then + printf "0 failed; " +else + printf "\033[31m%s\033[0m failed; " $fail +fi +printf "%s total\n" $((pass + fail)) + +if [ $fail -eq 0 ]; then + exit 0 +else + exit 1 +fi + -- cgit v1.2.3