compat.sh 639 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # This script checks that `zig build` will return an useful error message when
  3. # the Zig compiler is not compatible, instead of failing due to a syntax error.
  4. #
  5. # This script should be run on an UNIX system.
  6. zig_version=$(zig version)
  7. zig build -Dn=1 -Dhealed &> /dev/null 2>&1
  8. zig_ret=$?
  9. if [ "$zig_ret" -eq 0 ]; then
  10. printf "zig %s unexpectedly succeeded\n" "$zig_version"
  11. exit 1
  12. fi
  13. zig_error=$(zig build -Dn=1 -Dhealed 2>&1)
  14. echo "$zig_error" | grep -q "it looks like your version of zig is too old"
  15. zig_ret=$?
  16. if [ "$zig_ret" -ne 0 ]; then
  17. printf "zig %s is not compatible\n" "$zig_version"
  18. exit 1
  19. fi