self-check-dir.tap 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Check that tests using 'test-init.sh' create a proper temporary
  18. # directory, and run in it. Also check that we can prevent the
  19. # pre-population and the creation of such directory if we want.
  20. am_create_testdir=no
  21. . test-init.sh
  22. plan_ 5
  23. unset keep_testdirs
  24. # This needs to be consistent with what $AM_TEST_RUNNER_SHELL
  25. # deems to be the current working directory.
  26. cwd=$($AM_TEST_RUNNER_SHELL -c 'pwd') \
  27. || fatal_ "can't get current working directory"
  28. echo "$cwd"
  29. do_check ()
  30. {
  31. rm -rf _self.dir || framework_failure_ "cleaning up _self.dir"
  32. command_ok_ "$1 [$2]" $AM_TEST_RUNNER_SHELL -c "
  33. $2
  34. . test-init.sh
  35. # Don't fail if 'ls -l' fails; avoids possible racy spurious failures.
  36. pwd; ls -l || : # For debugging.
  37. $3
  38. " t/_self.sh
  39. }
  40. do_check 'testdir has the expected path' \
  41. 'unset am_create_testdir' \
  42. 'case $(pwd) in '"$cwd"'/t/_self.dir);; *) exit 1;; esac'
  43. do_check 'fully pre-populated testdir' \
  44. 'unset am_create_testdir' \
  45. 'test -f install-sh || exit 1
  46. test -f configure.ac || exit 1
  47. case $(pwd) in '"$cwd"'/t/_self.dir) : ;; *) exit 1;; esac'
  48. do_check 'testdir has the expected path' \
  49. 'am_create_testdir=empty' \
  50. 'case $(pwd) in '"$cwd"'/t/_self.dir) : ;; *) exit 1;; esac'
  51. do_check 'do not pre-populate testdir' \
  52. 'am_create_testdir=empty' \
  53. 'ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && exit 1; :'
  54. do_check 'do not create nor chdir in testdir' \
  55. 'am_create_testdir=no' \
  56. 'test ! -e t/_self.dir || exit 1
  57. grep "self-check-dir\.tap" Makefile || exit 1
  58. case $(pwd) in '"$cwd"') : ;; *) exit 1;; esac'
  59. :