tap-bad-prog.tap 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # TAP support:
  17. # - missing, unreadable, or not-executable test scripts cause proper
  18. # error reports
  19. . test-init.sh
  20. fetch_tap_driver
  21. plan_ 6
  22. cat >> configure.ac <<END
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am << 'END'
  26. TEST_LOG_DRIVER = $(srcdir)/tap-driver
  27. TESTS = none.test noread.test noexec.test
  28. none.test:
  29. END
  30. cat > noexec.test <<'END'
  31. #!/bin/sh
  32. echo 1..1
  33. echo ok 1
  34. END
  35. cp noexec.test noread.test
  36. chmod a-r noread.test
  37. $ACLOCAL
  38. $AUTOCONF
  39. $AUTOMAKE
  40. ./configure
  41. command_ok_ '"make check" returns non-zero exit status' \
  42. run_make -O -e FAIL check
  43. # FIXME: maybe grep for stricter error messages in the next checks?
  44. command_ok_ "non-existent test is reported" \
  45. grep '^ERROR: none\.test' stdout
  46. desc="non-executable test is reported"
  47. # Redirect output to avoid confusing automake's testsuite own TAP driver.
  48. if ./noexec.test >/dev/null; then
  49. skip_ -r "any file is executable" "$desc"
  50. else
  51. command_ok_ "$desc" -- grep '^ERROR: noexec\.test' stdout
  52. fi
  53. desc="non-readable test is reported"
  54. if test -r noread.test; then
  55. skip_ -r "any file is readable" "$desc"
  56. else
  57. command_ok_ "$desc" -- grep '^ERROR: noread\.test' stdout
  58. fi
  59. # Check that no spurious test result is reported. This is lower-priority
  60. # (and in fact the check currently fails).
  61. command_ok_ 'no spurious "missing plan" message' \
  62. -D TODO -- not grep 'missing.* plan' stdout
  63. command_ok_ 'no spurious results' \
  64. -D TODO -r 'still get "missing plan"' \
  65. count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=3
  66. :