summaryrefslogtreecommitdiff
path: root/run_tests.sh
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-27 12:01:33 +0100
committerubq323 <ubq323@ubq323.website>2024-06-27 12:05:27 +0100
commit991e694b558691264f82d80a7aa1b86ef3d2c92c (patch)
tree881946b076bdcc6545aa167ef7d544b6e16f9abb /run_tests.sh
parenta559125a2d7af771784614b7a2092cc7fb707345 (diff)
more tests
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-xrun_tests.sh53
1 files changed, 33 insertions, 20 deletions
diff --git a/run_tests.sh b/run_tests.sh
index 63b85aa..18885da 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -2,34 +2,47 @@
pass=0
fail=0
+skip=0
for testfile in tests/*.bth; do
outfile=${testfile%.bth}.out
- output="$(./bth $testfile 2>&1)"
- run_res=$?
- echo "$output" | diff $outfile - >/dev/null
- diff_res=$?
testname=${testfile#tests/}
testname=${testname%.bth}
- 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" "$(echo "$output" | head -n4)"
- printf "\texpected: "
- cat $outfile
- fail=$((fail + 1)) ;;
- esac
+ if [ ! -f "$outfile" ]; then
+ printf '\033[33mSKIP\033[0m %s (no output file)\n' "$testname"
+ skip=$((skip + 1))
+ else
+ output="$(./bth $testfile 2>&1)"
+ run_res=$?
+ echo "$output" | diff $outfile - >/dev/null
+ diff_res=$?
+ 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" "$(echo "$output" | head -n4)"
+ printf "\texpected: "
+ cat $outfile
+ fail=$((fail + 1)) ;;
+ esac
+ fi
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))
+
+pnum () {
+ if [ $1 -eq 0 ]; then
+ printf "0 %s; " "$2"
+ else
+ printf "\033[3%dm%d\033[0m %s; " $3 $1 "$2"
+ fi
+}
+
+pnum $pass passed 2
+pnum $fail failed 1
+pnum $skip skipped 3
+
+printf "%s total\n" $((pass + fail + skip))
if [ $fail -eq 0 ]; then
exit 0