run-testsuite 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. set -eu
  3. export TZ=UTC
  4. cd tests
  5. failing=0
  6. for i in *.testfile; do
  7. t=${i%%.testfile}
  8. printf "Running test: %s ... " "$t"
  9. m=
  10. for j in $(eval echo "${t}"*.magic); do
  11. if [ -f "$j" ]; then
  12. if [ -z "$m" ]; then
  13. m="$j"
  14. else
  15. m="$m:$j"
  16. fi
  17. fi
  18. done
  19. if [ "$m" ]; then
  20. export MAGIC="$m"
  21. else
  22. unset MAGIC
  23. fi
  24. if [ -f "${t}.flags" ]; then
  25. f="-$(cat "${t}.flags")"
  26. else
  27. f=
  28. fi
  29. expect="$(cat "${i%%.testfile}.result")"
  30. # shellcheck disable=SC2086
  31. got="$(file -b $f "$i" 2>/dev/null)"
  32. if [ "$got" = "$expect" ]; then
  33. echo 'pass'
  34. else
  35. cat <<__EOS__
  36. FAIL:
  37. expect: $expect
  38. got: $got
  39. __EOS__
  40. failing=$((failing+1))
  41. fi
  42. done
  43. if [ "$failing" -gt 0 ]; then
  44. echo "Fail count: $failing"
  45. exit 1
  46. fi
  47. exit 0