self-check-me.tap 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. # Sanity check for the automake testsuite.
  17. # Make sure that $me gets automatically defined by 'test-init.sh'.
  18. am_create_testdir=no
  19. . test-init.sh
  20. plan_ 12
  21. # This test becomes cumbersome if we keep the 'errexit' shell flag set.
  22. # And removing it is no big deal, as this test is a TAP-based one, so
  23. # that false positives remain very unlikely.
  24. set +e
  25. do_check ()
  26. {
  27. $AM_TEST_RUNNER_SHELL -c '
  28. am_create_testdir=no # Do not pollute the top-level directory.
  29. . test-init.sh
  30. echo me=$me
  31. ' "$1" | grep "^me=$2$"
  32. command_ok_ "me=$1" test $? -eq 0
  33. }
  34. for e in sh tap; do
  35. do_check foo-bar-.$e 'foo-bar-'
  36. do_check _foo__bar.$e '_foo__bar'
  37. do_check 012.$e '012'
  38. do_check a.b.c.$e 'a\.b\.c'
  39. done
  40. do_check foo.bar 'foo\.bar'
  41. do_check abc. 'abc\.'
  42. # A definition of $me in the environment should be ignored.
  43. s=$(me=bad $AM_TEST_RUNNER_SHELL -c '
  44. # Do not pollute the top-level directory.
  45. am_create_testdir=no
  46. . test-init.sh
  47. echo me=$me
  48. ' foo.sh)
  49. command_ok_ "override of \$me before test-init.sh causes no error" \
  50. test $? -eq 0
  51. r='ok'
  52. printf '%s\n' "$s" | grep '^me=foo$' || r='not ok'
  53. printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
  54. result_ "$r" "\$me from the environment is ignored"
  55. unset r
  56. :