diff options
author | ubq323 <ubq323@ubq323.website> | 2024-08-17 12:53:10 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-08-17 12:53:10 +0100 |
commit | 9b75f546b3a171a4e5afc7ed9d4969f73113c2c9 (patch) | |
tree | ce9adb55b89696f9f586143b107c1d30ed70c7c8 /run_tests.sh | |
parent | 05cfb9bf2461785ec621b490747f48b96344017f (diff) |
skip glob for tests
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-x | run_tests.sh | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/run_tests.sh b/run_tests.sh index 16201b5..e852582 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -4,27 +4,39 @@ pass=0 fail=0 skip=0 +skipglob="$1" + + +skip() { + printf '\033[33mSKIP\033[0m %s (%s)\n' "$testname" "$1" + skip=$((skip + 1)) +} + for testfile in tests/*.bth; do outfile=${testfile%.bth}.out testname=${testfile#tests/} testname=${testname%.bth} if [ ! -f "$outfile" ]; then - printf '\033[33mSKIP\033[0m %s (no output file)\n' "$testname" - skip=$((skip + 1)) - else - output="$(./bth "$testfile" 2>&1)" - 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 + skip "no output file" + continue fi + case "$testname" in + $skipglob) skip "matches skip glob $skipglob" + continue ;; + esac + + output="$(./bth "$testfile" 2>&1)" + 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 done echo |